Part Number Hot Search : 
LSH20 WM7211E FBP005 C4052 M66257FP NSPW570 R24D05 S1215
Product Description
Full Text Search
 

To Download M38D2 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  rev.3.02 apr 10, 2008 page 1 of 131 rej03b0177-0302 description the 38d2 group is the 8-bit mic rocomputer based on the 740 family core technology. the 38d2 group is pin-compatible with the 38c2 group. the 38d2 group has an lcd drive control circuit, an a/d converter, a serial interface, and a rom correction function and on-chip oscillator as additional functions. the qzrom version and the flash memory version are available. the flash memory version does not have a selection function for the oscillation start mode. only the on-chip oscillator starts oscillating. the various microcomputers includ e variations of memory size, and packaging. for details, refer to the section on part numbering. features ? basic machine-language instructions ................. ........... ..... 71 ? the minimum instruction execution time ................... 0.32 s (at 12.5 mhz osci llation frequency) ? memory size (qzrom version) rom ........................................................ 16 k to 60 k bytes ram ........... ........... ........... ........... ........... .... 640 to 2048 bytes ? memory size (flash memory version) rom ...................................................................... 60 k bytes ram ........... ........... ........... ........... ........... ............ ... 2048 bytes ? programmable input/output ports .. 51 (common to seg: 24) ? interrupts ............................................. 18 sources, 16 vectors ? timers ..................................................... 8-bit 4, 16-bit 2 ? serial interface ....... 8-bit 2 (uart or clock-synchronized) ? pwm .......... 10-bit 2, 16-bit 1 (common to igbt output) ? a/d converter .......... ........... ............ ......... 10-bit 8 channels (a/d converter can be operated in low-speed mode.) ? watchdog timer ......................................................... 8-bit 1 ? rom correction function ....................... 32 bytes 2 vectors ? led direct drive port ............................................................ 8 (average current: 15 ma, peak current: 30 ma, total current: 90 ma) ? lcd drive control circuit bias ............................................................................ 1/2, 1/3 duty .............................................................................. 2, 3, 4 common output .................................................................... 4 segment output ................................................................... 24 ? main clock generating circuit ............................................... 1 (connect to external ceramic resonator or on-chip oscillator) ? sub-clock generating circuit ..................................................1 (connect to external qua rtz-crystal oscillator) ? power source voltage (qzrom version) [in frequency/2 mode] f(x in ) 12.5 mhz.............................................. 4.5 to 5.5 v f(x in ) 8 mhz................................................... 4.0 to 5.5 v f(x in ) 4 mhz................................................... 2.0 to 5.5 v f(x in ) 2 mhz................................................... 1.8 to 5.5 v [in frequency/4 mode] f(x in ) 16 mhz................................................. 4.5 to 5.5 v f(x in ) 8 mhz................................................... 2.0 to 5.5 v f(x in ) 4 mhz................................................... 1.8 to 5.5 v [in frequency/8 mode] f(x in ) 16 mhz................................................. 4.5 to 5.5 v f(x in ) 8 mhz................................................... 2.0 to 5.5 v f(x in ) 4 mhz................................................... 1.8 to 5.5 v [in low-speed mode].............................................. 1.8 to 5.5 v note. 12.5 mhz < f(x in ) 16 mhz is not available in the fre- quency/2 mode. ? power source voltage (flash memory version) [in frequency/2 mode] f(x in ) 12.5 mhz.............................................. 4.5 to 5.5 v f(x in ) 8 mhz................................................... 4.0 to 5.5 v f(x in ) 4 mhz................................................... 2.7 to 5.5 v [in frequency/4 mode] f(x in ) 16 mhz................................................. 4.5 to 5.5 v f(x in ) 8 mhz................................................... 2.7 to 5.5 v [in frequency/8 mode] f(x in ) 16 mhz................................................. 4.5 to 5.5 v f(x in ) 8 mhz................................................... 2.7 to 5.5 v [in low-speed mode].............................................. 2.7 to 5.5 v note. 12.5 mhz < f(x in ) 16 mhz is not available in the fre- quency/2 mode. ? power dissipati on (qzrom version) ? in frequency/2 mode ..................................... typ. 32 mw (v cc = 5 v, f(x in ) = 12.5 mhz, ta = 25 c) ? in low-speed mode ........................................ typ. 18 w (v cc = 2.5 v, f(x in ) = stop, f(x cin ) = 32 khz, ta = 25 c) ? power dissipation (f lash memory version) ? in frequency/2 mode ..................................... typ. 20 mw (v cc = 5 v, f(x in ) = 12.5 mhz, ta = 25 c) ? in low-speed mode ...................................... typ. 1.1 mw (v cc = 2.7 v, f(x in ) = stop, f(x cin ) = 32 khz, ta = 25 c) ? operating temperature range ............................... ? 20 to 85 c flash memory mode ? program/erase voltage ............................. v cc = 2.7 to 5.5 v ? program method ....................... programming in unit of byte ? erase method ...... ........... ........... ........... ........... .. block erasing ? program/erase control by software command application household products, cons umer electronics, etc. 38d2 group single-chip 8-bit cmos microcomputer rej03b0177-0302 rev.3.02 apr 10, 2008
rev.3.02 apr 10, 2008 page 2 of 131 rej03b0177-0302 38d2 group fig. 1 pin configuration (lqfp package) package type : plqp0064ga-a(64p6u-a)/plqp0064kb-a(64p6q-a) p0 6 /seg 6 p0 7 /seg 7 p1 0 /seg 8 p1 1 /seg 9 p1 2 /seg 10 p1 3 /seg 11 p1 4 /seg 12 p1 5 /seg 13 p1 6 /seg 14 p1 7 /seg 15 61 32 31 30 29 28 27 26 25 24 23 22 21 6 7 8 9 10111213141516 45 44 43 42 41 40 39 38 37 36 35 34 33 p2 4 /seg 20 p2 5 /seg 21 com 2 com 1 com 0 p2 7 /seg 23 /v l2 p2 6 /seg 22 /v l1 com 3 p0 3 /seg 3 /(kw 7 ) p 0 4 / s e g 4 p0 5 /seg 5 p5 1 /int 1 p5 6 /s clk1 /(kw 2 ) p5 5 /t x d 1 /(kw 1 ) p5 4 /r x d 1 /(kw 0 ) p5 3 /t 4out /pwm 1 p2 0 /seg 16 p2 1 /seg 17 p2 2 /seg 18 p2 3 /seg 19 49 50 51 52 53 48 47 46 62 63 64 12345 20 19 18 17 55 56 57 58 59 60 M38D2xgxfp/hp M38D29fffp/hp 54 p3 6 /t 2out /ckout/(led 6 ) p5 2 /t 3out /pwm 0 vref v l3 p4 7 /rtp 1 /an 7 p4 6 /rtp 0 /an 6 p3 2 /t x d 2 /(led 2 ) p3 1 /s clk2 /(led 1 ) p3 3 /r x d 2 /(led 3 ) p5 0 /int 0 av ss p0 2 /seg 2 /(kw 6 ) p0 1 /seg 1 /(kw 5 ) p0 0 /seg 0 /(kw 4 ) p5 7 /s rdy1 /(kw 3 ) p3 5 /t xout1 /(led 5 ) p3 4 /int 2 /(led 4 ) p3 0 /s rdy2 /(led 0 ) p6 0 /cntr 1 p3 7 /cntr 0 /t xout2 /(led 7 ) x out p4 3 /an 3 p4 2 /adkey/an 2 p4 4 /an 4 p4 5 /an 5 v ss p4 1 /o out1 /an 1 p4 0 /o out0 /an 0 oscsel (note 1) p6 2 /x cout p6 1 /x cin v cc x in reset pin configuration (top view) note 1 :cnv ss in flash memory version
rev.3.02 apr 10, 2008 page 3 of 131 rej03b0177-0302 38d2 group note: 1. 12.5 mhz < f(x in ) 16 mhz is not available in the frequency/2 mode. table 1 performance overview parameter function number of basic instructions 71 instruction execution time 0.32 s (minimum instruction, oscillation fr equency 12.5 mhz) oscillation frequency 16 mhz (maximum) (1) memory sizes (qzrom version) rom 16 k to 60 k bytes ram 640 to 2048 bytes memory sizes (flash memory version) rom 60 k bytes ram 2048 bytes i/o port p0-p5, p6 0 -p6 2 8-bit 6, 3-bit 1 (24 pins sharing seg) interrupt 18 sources, 16 vectors (includes key input interrupt) timer 8-bit 4, 16-bit 2 serial interface 8-bit 2 (uart or clock-synchronized) pwm 10-bit 2, 16-bit 1 (common to igbt output) a/d converter 10-bit 8 (operated in low-speed mode) watchdog timer 8-bit 1 rom correction function 32 bytes 2 vectors led direct drive port 8 (average current: 15 ma, peak current: 30 ma, total current: 90 ma) lcd drive control circuit bias 1/2, 1/3 duty 2, 3, 4 common output 4 segment output 24 main clock generating circuits built-in (connect to external ceramic resonator or on-chip oscillator) sub-clock generating circuits built-in (connect to exter nal quartz-crystal oscillator) power source voltage (qzrom version) in frequency/2 mode (1) f(x in ) 12.5 mhz 4.5 to 5.5 v f(x in ) 8 mhz 4.0 to 5.5 v f(x in ) 4 mhz 2.0 to 5.5 v f(x in ) 2 mhz 1.8 to 5.5 v in frequency/4 mode f(x in ) 16 mhz 4.5 to 5.5 v f(x in ) 8 mhz 2.0 to 5.5 v f(x in ) 4 mhz 1.8 to 5.5 v in frequency/8 mode f(x in ) 16 mhz 4.5 to 5.5 v f(x in ) 8 mhz 2.0 to 5.5 v f(x in ) 4 mhz 1.8 to 5.5 v in low-speed mode 1.8 to 5.5 v power source voltage (flash memory version) in frequency/2 mode (1) f(x in ) 12.5 mhz 4.5 to 5.5 v f(x in ) 8 mhz 4.0 to 5.5 v f(x in ) 4 mhz 2.7 to 5.5 v in frequency/4 mode f(x in ) 16 mhz 4.5 to 5.5 v f(x in ) 8 mhz 2.7 to 5.5 v in frequency/8 mode f(x in ) 16 mhz 4.5 to 5.5 v f(x in ) 8 mhz 2.7 to 5.5 v in low-speed mode 2.7 to 5.5 v power dissipation (qzrom version) in frequency/2 mode std. 32 mw (vcc = 5 v, f(x in ) = 12.5 mhz, ta = 25 c) in low-speed mode std. 18 w (vcc = 2.5 v, f(x in ) = stop, f(x cin ) = 32 khz, ta = 25 c) power dissipation (flash memory version) in frequency/2 mode std. 20 mw (vcc = 5 v, f(x in ) = 12.5 mhz, ta = 25 c) in low-speed mode std. 1.1 mw (vcc = 2.7 v, f(x in ) = stop, f(x cin ) = 32 khz, ta = 25 c) input/output characteristics input/output withstand voltage v cc output current 10 ma operating temperature range -20 to 85 c device structure cmos silicon gate package 64-pin plastic molded lqfp
rev.3.02 apr 10, 2008 page 4 of 131 rej03b0177-0302 38d2 group fig. 2 functional block diagram t i m e r p o r t p 0 ( 8 ) 8 p o r t p 1 ( 8 ) 8 p o r t p 2 ( 8 ) 8 i n t e r n a l p e r i p h e r a l f u n c t i o n a / d c o n v e r t e r 1 0 - b i t s 8 - c h a n n e l s s e r i a l i / o s e r i a l i / o 1 ( u a r t o r c l o c k s y n c h r o n o u s ) s e r i a l i / o 2 ( u a r t o r c l o c k s y n c h r o n o u s ) l c d d r i v e c o n t r o l c i r c u i t 4 c o m 2 4 s e g t i m e r x ( 1 6 b i t s ) p w m ( 1 6 b i t s ) i g b t o u t p u t t i m e r y ( 1 6 b i t s ) t i m e r 1 ( 8 b i t s ) t i m e r 2 ( 8 b i t s ) t i m e r 3 ( 8 b i t s ) p w m 0 ( 1 0 b i t s ) t i m e r 4 ( 8 b i t s ) p w m 1 ( 1 0 b i t s ) s y s t e m c l o c k g e n e r a t i o n x i n ? x o u t ( m a i n c l o c k ) x c i n ? x c o u t ( s u b - c l o c k ) m e m o r y r o m r a m f o r l c d d i s p l a y ( 1 2 b y t e s ) r a m c p u c o r e 8 8 p o r t p 4 ( 8 ) p o r t p 5 ( 8 ) p o r t p 6 ( 3 ) p o r t p 3 ( 8 ) 8 3 w a t c h d o g t i m e r o n - c h i p o s c i l l a t o r r o m c o r r e c t i o n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - functional block diagram
rev.3.02 apr 10, 2008 page 5 of 131 rej03b0177-0302 38d2 group pin description table 2 pin description (1) pin name function function except a port function v cc , v ss power source ? apply 1.8 to 5.5 v to v cc , and 0 v to v ss . reset reset input ? reset input pin for active ?l?. x in clock input ? input and output pins for the main clock generating circuit. ? connect a ceramic resonator or a quar tz-crystal oscillator between the x in and x out pins to set the oscillation frequency. when an external clock is used, connect the clock source to x in , and leave x out pin open. ? feedback resistor is built in between x in pin and x out pin. x out clock output v l3 lcd power source ? input 0 v l1 v l2 v l3 voltage. ? input 0 ? v l3 voltage to lcd. com 0 ? com 3 common output ? lcd common output pins. ?com 2 and com 3 are not used at 1/2 duty ratio. ?com 3 is not used at 1/3 duty ratio. p0 0 /seg 0 /(kw 4 ) ? p0 3 /seg 3 /(kw 7 ) i/o port p0 ? 8-bit i/o port. ? cmos compatible input level. ? cmos 3-state output structure. ? i/o direction register allows each pin to be individually programmed as either input or output. ? pull-up control is enabled in a bit unit. ? lcd segment output pins ? key input interrupt input pins p0 4 /seg 4 ? p0 7 /seg 7 p1 0 /seg 8 ? p1 7 /seg 15 i/o port p1 ? 8-bit i/o port. ? cmos compatible input level. ? cmos 3-state output structure. ? i/o direction register allows each pin to be individually programmed as either input or output. ? pull-up control is enabled in a bit unit. p2 0 /seg 16 ? p2 5 /seg 21 i/o port p2 ? 8-bit i/o port. ? cmos compatible input level. ? cmos 3-state output structure. ? i/o direction register allows each pin to be individually programmed as either input or output. ? pull-up control is enabled in a bit unit. p2 6 /seg 22 /v l1 p2 7 /seg 23 /v l2 ? lcd power source pins p3 0 /s rdy2 /(led 0 ) p3 1 /s clk2 /(led 1 ) p3 2 /txd 2 /(led 2 ) p3 3 /rxd 2 /(led 3 ) i/o port p3 ? 8-bit i/o port. ? cmos compatible input level. ? cmos 3-state output structure. ? i/o direction register allows each pin to be individually programmed as either input or output. ? pull-up control is enabled in 4-bit unit. ? serial i/o2 function pins p3 4 /int 2 /(led 4 ) ? external interrupt pin p3 5 /t xout1 /(led 5 ) p3 6 /t 2out /ckout/ (led 6 ) ? timer x, timer 2 output pins p3 7 /cntr 0 /t xout2 / (led 7 ) ? timer x function pin p4 0 /o out0 /an 0 p4 1 /o out1 /an 1 i/o port p4 ? 8-bit i/o port. ? cmos compatible input level. ? cmos 3-state output structure. ? i/o direction register allows each pin to be individually programmed as either input or output. ? pull-up control is enabled in 4-bit unit. ? a/d convertor input pins ? oscillation external output pins p4 2 /an 2 /adkey ?adkey p4 3 /an 3 ? p4 5 /an 5 p4 6 /rtp 0 /an 6 p4 7 /rtp 1 /an 7 ? real time port function pins p5 0 /int 0 p5 1 /int 1 i/o port p5 ? 8-bit i/o port. ? cmos compatible input level. ? cmos 3-state output structure. ? i/o direction register allows each pin to be individually programmed as either input or output. ? pull-up control is enabled in 4-bit unit ? external input pins p5 2 /t 3out /pwm 0 p5 3 /t 4out /pwm 1 ? timer 3, timer 4 output pins ? pwm output pins p5 4 /rxd 1 /(kw 0 ) p5 5 /txd 1 /(kw 1 ) p5 6 /s clk1 /(kw 2 ) p5 7 /s rdy1 /(kw 3 ) ? serial i/o1 function pins ? key input interrupt input pins
rev.3.02 apr 10, 2008 page 6 of 131 rej03b0177-0302 38d2 group table 3 pin description (2) pin name function function except a port function p6 0 /cntr 1 i/o port p6 ? .3-bit i/o port. ? cmos compatible input level. ? cmos 3-state output structure. ? i/o direction register allows each pin to be individually programmed as either input or output. ? pull-up control is enabled in 3-bit unit ? timer y function pins p6 1 /x cin p6 2 /x cout ? sub clock generating circuit i/o pins (oscillator connected) oscsel (only qzrom version) oscillation start selection pin ? whether oscillation starts by an oscillator between the x in and x out pins or an on-chip oscillator is selected. ?v pp power source input pin in the qzrom writing mode. cnv ss (only flash memory version) cnv ss ? pin for controlling the operating mode of the chip. connect to v ss . v ref analog reference voltage ? reference voltage input pin for a/d converter. av ss analog power source ? analog power source input pin for a/d converter. connect to v ss.
rev.3.02 apr 10, 2008 page 7 of 131 rej03b0177-0302 38d2 group part numbering fig. 3 part numbering product M38D2 4 g 6 - xxx fp package type fp: plqp0064ga-a package hp: plqp0064kb-a package rom number omitted in the shipped in blank version. rom memory size 1 : 4096 bytes 9 : 36864 bytes 2 : 8192 bytes a : 40960 bytes 3 : 12288 bytes b : 45056 bytes 4 : 16384 bytes c : 49152 bytes 5 : 20480 bytes d : 53248 bytes 6 : 24576 bytes e : 57344 bytes 7 : 28672 bytes f : 61440 bytes 8 : 32768 bytes the first 128 bytes and the last 2 bytes of rom are reserved areas ; they cannot be used. memory type g : qzrom version f : flash memory version ram size 0 : 192 bytes 1 : 256 bytes 2 : 384 bytes 3 : 512 bytes 4 : 640 bytes 5 : 768 bytes 6 : 896 bytes 7 : 1024 bytes 8 : 1536 bytes 9 : 2048 bytes
rev.3.02 apr 10, 2008 page 8 of 131 rej03b0177-0302 38d2 group group expansion renesas plans to expand the 38d2 group as follows. memory size ? rom size ................................................... 16 k to 60 k bytes ? ram size ...... ........... ........... ............ ............ 640 to 2048 bytes ? rom size ................................................................ 60 k bytes ? ram size ........ ............ ........... ........... ........... .......... 2048 bytes packages ? plqp0064ga-a ...............0.8 mm-pitch plastic molded lqfp ? plqp0064kb-a ...............0.5 mm-pitch plastic molded lqfp fig. 4 memory expansion plan 32k 28k 24k 20k 16k 12k 8k 4k 256 384 512 640 768 896 1,024 192 40k 48k 1,536 2,048 56k 60k rom size (bytes) ram size (bytes) M38D24g4 M38D24g6 products under development or planning : the development schedule and specification may be revised without notice. M38D28g8 memory expansion plan under development M38D29gf/ff M38D29gc
rev.3.02 apr 10, 2008 page 9 of 131 rej03b0177-0302 38d2 group currently supported produc ts are listed below . table 4 as of august 2007 part no. rom size (bytes) rom size for user in ( ) ram size (bytes) package remarks M38D29gf-xxxfp 61440 (61310) 2048 plqp0064ga-a M38D29gf-xxxhp plqp0064kb-a M38D29gffp plqp0064ga-a blank M38D29gfhp plqp0064kb-a blank M38D29gc-xxxfp 49152 (49022) 2048 plqp0064ga-a M38D29gc-xxxhp plqp0064kb-a M38D29gcfp plqp0064ga-a blank M38D29gchp plqp0064kb-a blank M38D28g8-xxxfp 32768 (32638) 1536 plqp0064ga-a M38D28g8-xxxhp plqp0064kb-a M38D28g8fp plqp0064ga-a blank M38D28g8hp plqp0064kb-a blank M38D24g6-xxxfp 24576 (24446) 640 plqp0064ga-a M38D24g6-xxxhp plqp0064kb-a M38D24g6fp plqp0064ga-a blank M38D24g6hp plqp0064kb-a blank M38D24g4-xxxfp 16384 (16254) 640 plqp0064ga-a M38D24g4-xxxhp plqp0064kb-a M38D24g4fp plqp0064ga-a blank M38D24g4hp plqp0064kb-a blank M38D29fffp 61440 2048 plqp0064ga-a flash memory version M38D29ffhp plqp0064kb-a support products
rev.3.02 apr 10, 2008 page 10 of 131 rej03b0177-0302 38d2 group note: 1. for detailed specifications, confirm the descriptions in the datasheet. notes on differences betw een qzrom and flash mem- ory versions (1) the memory map, the wr iting modes and programming circuits vary because of the differences in their internal memories. (2) the oscillation parameters of x in -x out and x cin -x cout may vary. (3) the qzrom version and th e flash memory version mcus differ in their manufacturing processes, built-in rom, and layout patterns. because of these differences, characteristic values, operation margins, a/d conversion accuracy, noise immunity, and noise radiation may vary within the specified range of electrical characteristics. (4) when switching from the flash memory version to the qzrom version, implement sy stem evaluations equivalent to those implemented in the flash memory version. (5) the both operations except the electrical characteristics are same at the emulator (emu lator mcu board: M38D29t- rlfs). table 5 differences between qzrom and flash memory versions qzrom version flash memory version oscillation circuit at reset and at returning from stop mode main clock x in or on-chip oscillator selectable by oscsel pin on-chip oscillator termination of oscel/cnv ss pin oscsel = ?h? oscsel = ?l? cnv ss = ?l? main clock oscillation at reset and at returning from stop mode oscillation on stop stop on-chip oscillator oscillati on at reset and at returning from stop mode stop oscillation on oscillation on system clock oscillation at reset and at returning from stop mode f(x in )/8 f(oco)/32 f(oco)/32 mounting of main clock oscillat ion circuit required optional optional on-chip oscillator oscill ation in low speed-mode stop stop by setting the on-chip oscillator stop bit because it is not stopped. writing ?1? to on-chip oscillator stop bit in on-chip oscillator mode on-chip oscillator is stopped on-chip oscillator is not stopped reset input ?l? pulse width 2 s or more 2 ms or more absolute maximum rating: oscsel/cnv ss pin ? 0.3 to 8.0 ? 0.3 to v cc + 0.3 minimum operating power source voltage 1.8 v 2.7 v a/d converter minimum operating power source voltage 2.0 v 2.7 v
rev.3.02 apr 10, 2008 page 11 of 131 rej03b0177-0302 38d2 group functional description central processing unit (cpu) the 38d2 group uses the standard 740 family instruction set. refer to the 740 family software manual for details on the instruction set. machine-resident 740 family in structions are as follows: the fst and slw instructions cannot be used. the stp, wit, mul, and div instructions can be used. the central processing unit (cpu ) has six registers. figure 5 shows the 740 family cpu register structure. [accumulator (a)] the accumulator is an 8-bit re gister. data operations such as arithmetic data transfer, etc., are executed mainly through the accumulator. [index register x (x)] the index register x is an 8-bit register. in the index addressing modes, the value of the operand is added to the contents of register x and specifies the real address. [index register y (y)] the index register y is an 8-bit re gister. in partial instruction, the value of the operand is added to the contents of register y and specifies the real address. [stack pointer (s)] the stack pointer is an 8-bit regi ster used during subroutine calls and interrupts. this register indi cates start address of stored area (stack) for storing registers during subroutine calls and interrupts. the low-order 8 bits of the stack address are determined by the contents of the stack pointer. th e high-order 8 bits of the stack address are determined by the st ack page selection bit. if the stack page selection bit is ?0?, the high-order 8 bits becomes ?00 16 ?. if the stack page selection bi t is ?1?, the high-order 8 bits becomes ?01 16 ?. the operations of pushing register contents onto the stack and popping them from the stack are shown in figure 6. table 6 shows the push and pop instructions of accumulator or processor status register. store registers other than those described in figure 6 with program when the user needs them during interrupts or subroutine calls. [program counter (pc)] the program counter is a 16-bit counter consisting of two 8-bit registers pc h and pc l . it is used to indicate the address of the next instruction to be executed. fig. 5 740 family cp u register structure processor status register (ps) carry flag zero flag interrupt disable flag decimal mode flag break flag index x mode flag overflow flag negative flag b7 b0 b15 program counter stack pointer index register y index register x accumulator a x y s pc l pc h c z i d b t v n b7 b0 b7 b0 b7 b0 b7 b0 b7 b0
rev.3.02 apr 10, 2008 page 12 of 131 rej03b0177-0302 38d2 group fig. 6 register push and pop at in terrupt generation and subroutine call interrupt request on-going routine m(s) (pc h ) (s) (s) ? 1 m(s) (pc l ) (s) (s) ? 1 ..... execute rts subroutine (s) (s) + 1 (pc l ) m(s) (s) (s) + 1 (pc h ) m(s) m(s) (pc h ) (s) (s) ? 1 m(s) (pc l ) (s) (s) ? 1 m(s) (ps) (s) (s) ? 1 interrupt service routine (s) (s) + 1 (ps) m(s) (s) (s) + 1 (pc l ) m(s) (s) (s) + 1 (pc h ) m(s) execute jsr execute rti (1) push return address on stack push contents of processor status register on stack i flag is set from ?0? to ?1? fetch the jump vector pop contents of processor status register from stack pop return address from stack pop return address from stack push return address on stack note1 : condition for acceptance of an interrupt request here interrupt disable flag is ?0? and interrupt enable bit corresponding to each interrupt source is ?1? - - - - - - - - - - - - table 6 push and pop instructions of accumulator or processor status register push instruction to stack p op instruction from stack accumulator pha pla processor status register php plp
rev.3.02 apr 10, 2008 page 13 of 131 rej03b0177-0302 38d2 group [processor status register (ps)] the processor status register is an 8-bit register consisting of 5 flags which indicate the status of the processor after an arithmetic operation and 3 fl ags which decide mcu operation. branch operations can be perf ormed by testing the carry (c) flag, zero (z) flag, overflow (v) flag, or the negative (n) flag. in decimal mode, the z, v, n flags are not valid. ? bit 0: carry flag (c) the c flag contains a carry or borrow generated by the arithmetic logic unit (alu) i mmediately after an arithmetic operation. it can also be changed by a shift or rotate instruction. ? bit 1: zero flag (z) the z flag is set to ?1? if the result of an immediate arithmetic operation or a data transfer is ?0?, and set to ?0? if the result is anything other than ?0?. ? bit 2: interrupt disable flag (i) the i flag disables all inte rrupts except for the interrupt generated by the brk instruction. interrupts are disabled when the i flag is ?1?. ? bit 3: decimal mode flag (d) the d flag determines whether additions and subtractions are executed in binary or decimal. binary arithmetic is executed when this flag is ?0?; decimal arithmetic is executed when it is ?1?. decimal correction is automatic in decimal mode. only the adc and sbc instructions can be used for decimal arithmetic. ? bit 4: break flag (b) the b flag is used to indicate that the current interrupt was generated by the brk instructio n. when the brk instruction is generated, the b flag is set to ?1? automatically. when the other interrupts are generated, the b flag is set to ?0?, and the processor status register is pushed onto the stack. ? bit 5: index x mode flag (t) when the t flag is ?0?, arithmetic operations are performed between accumulator and memory. when the t flag is ?1?, direct arithmetic operations a nd direct data transfers are enabled between memory locations. ? bit 6: overflow flag (v) the v flag is used during the addition or subtraction of one byte of signed data. it is set if the result exceeds +127 to -128. when the bit instruction is executed, bit 6 of the memory location operated on by the bit instruction is stored in the overflow flag. ? bit 7: negative flag (n) the n flag is set to ?1? if the result of an arithmetic operation or data transfer is negative. when the bit instruction is executed, bit 7 of the memory location operated on by the bit instruction is stored in the negative flag. table 7 set and clear instructions of each bit of processor status register c flag z flag i flag d flag b flag t flag v flag n flag set instruction sec ? sei sed ? set ?? clear instruction clc ? cli cld ? clt clv ?
rev.3.02 apr 10, 2008 page 14 of 131 rej03b0177-0302 38d2 group [cpu mode register (cpum)] 003b 16 the cpu mode register contains th e stack page sele ction bit, etc. this register is allocated at address 003b 16 . after the system is released from reset, the mode depends on the oscsel pin state in the qzrom version. when the oscsel pin state is gnd level, only the on-chip oscillator starts oscillation. the x in -x out oscillation stops oscillating, and x cin and x cout pins function as i/o ports. the operating mode is the on- chip oscillator mode. when the oscsel pin state is vcc level, the x in -x out oscillation divided by 8 starts oscillation. the on-chip oscillator stops oscillating, and the x cin and x cout pins function as i/o ports. the operating mode is the frequency/8 mode. in the flash memory version, onl y the on-chip oscillator starts oscillating. the x in -x out oscillation stops os cillating, and the x cin and x cout pins function as i/o ports. the operating mode is the on-chip oscillator mode. when the main clock or sub-clock is used, after the x in -x out oscillation and the x cin -x cout oscillation are enabled, wait in the on-chip oscillator mode etc. until the oscillation stabilizes, and then switch the operation mode. when the main clock is not used (x in -x out oscillation and an external clock input are not used), connect the x in pin to v cc through a resistor and leave x out open. [cpu mode register 2 (cpum2)] 0011 16 the cpu mode register 2 contains the control bits for the on-chip oscillator. the cpu mode register 2 is allocated at address 0011 16 . fig. 7 structure of cpu mode register on-chip oscillator stop bit 0 : oscillating 1 : stopped not used (do not write ?1?) not used (returns ?0? when read) not used (do not write ?1?) processor mode bits b1 b0 0 0 : single-chip mode 0 1 : 1 0 : 1 1 : stack page selection bit 0 : 0 page 1 : 1 page internal system cl ock selection bit 0 : main clock se lected (includes oco, x in ) 1 : x cin ?x cout selected port xc switch bit 0 : i/o port function (oscillation stop) 1 : x cin ?x cout oscillating function x in ?x out oscillation stop bit 0 : oscillating 1 : stopped main clock division ratio select ion bit (valid only when cm3=0) b7 b6 0 0 : f(x in )/2 (frequency/2 mode) 0 1 : f(x in )/8 (frequency/8 mode) 1 0 : f(x in )/4 (frequency/4 mode) 1 1 : on-chip oscillator b7 b0 cpu mode register 2 cpum2 (address 0011 16 , qzrom version, oscsel=l, initial value: 00 16 ) ( qzrom version, oscsel=h, initial value: 01 16 ) ( flash memory version, initial value: 00 16 ) cm8 b7 b0 cpu mode register cpum (address 003b 16 , qzrom version, oscsel=l, initial value: e0 16 ) ( qzrom version, oscsel=h, initial value: 40 16 ) ( flash memory version, initial value: e0 16 ) cm0 cm1 cm2 cm3 cm4 cm5 cm6 cm7 not available notes 1 : when the on-chip oscillator is selected by the watc hdog timer count source selection bit 2 (bit 5 of watchdog timer control register (address 0029 16 )), the on-chip oscillator does not stop even when the on-chip oscillator stop bit is set to ?1?. also, when the low-speed mode is set, the on-chip oscillator stops regardless of the value of this bit in the qzrom version. the on-chip oscillator does not st op in the flash memory version, so set this bit to ?1? to stop the oscillation. in on-chip oscillator mode, even if this bit is set to ?1?, the on-chip oscillator does not stop in the flash memory version, but stop s in the qzrom version. 2 : in low-spee d mode, the x cin -x cout oscillation stops if the port x c switch bit is set to ?0?. 3 : in x in mode, the x in -x out oscillation does not stop even if the x in -x out oscillation stop bit is set to ?1?. 4 : 12.5 mhz < f(x in ) 16 mhz is not available in the frequency/2 mode. ( 1 ) ( 4 ) ( 2 ) ( 3 )
rev.3.02 apr 10, 2008 page 15 of 131 rej03b0177-0302 38d2 group fig. 8 switch procedure of cpu mode register after releasing reset n y low-speed/x in mode ? start the oscillation (bits 4 and 5 of cpum) oscillator starts oscillation. do not change bit 3, bit 6 and bit 7 of cpum until oscillation stabilizes. select internal system clock (bit 3 of cpum or bit 7, 6 = ?01?) wait by on-chip oscillator operation until establishment of oscillator clock switch the main clock division ratio selection bit (bit 7, 6 = ?00? or ?10?) start with an on-chip oscillator. initial value of cpum is e0 16 . initial value of cpum2 is 00 16 . as for the details of condition for transition among each mode, refer to the state transition of system clock. system can operate in on-chip oscillator mode until oscillation stabilize. select internal system clock. do not change bit 3, bit 6 and bit 7 of cpum at the same time. select main clock division ratio. switch to frequency/2 or frequency/4 mode here, if necessary. main routine reset l oscsel ? after releasing reset wait by operation until establishment h the cpu starts its operation in the built-in x in mode. initial value of cpum is 40 16 . initial value of cpum2 is 01 16 . after releasing reset n y low-speed/x in mode ? start the oscillation (bits 4 and 5 of cpum) oscillator starts oscillation. do not change bit 3, bit 6 and bit 7 of cpum until oscillation stabilizes. select internal system clock (bit 3 of cpum or bit 7, 6 = ?01?) wait by on-chip oscillator operation until establishment of oscillator clock switch the main clock division ratio selection bit (bit 7, 6 = ?00? or ?10?) start with an on-chip oscillator. initial value of cpum is e0 16 . initial value of cpum2 is 00 16 . as for the details of condition for transition among each mode, refer to the state trans ition of system clock. system can operate in on-ch ip oscillator mode until oscillation stabilize. select internal system clock. do not change bit 3, bit 6 and bit 7 of cpum at the same time. select main clock division ratio. switch to frequency/2 or 4 mode here, if necessary. main routine reset
rev.3.02 apr 10, 2008 page 16 of 131 rej03b0177-0302 38d2 group memory ? special function register (sfr) area the special function register area in the zero page contains control registers such as i/o ports and timers. ? ram ram is used for data storage and for stack area of subroutine calls and interrupts. ?rom in the qzrom version, the first 128 kbytes and the last 2 bytes are reserved for device testing and the rest is the user area. also, 1 byte of address ffdb 16 is reserved. in the flash memory version, programming and erase operations can be performed to reserved rom areas. ? interrupt vector area the interrupt vector area contai ns reset and interrupt vectors. ? zero page access to this area with only 2 bytes is possible in the zero page addressing mode. ? special page access to this area with only 2 by tes is possible in the special page addressing mode. ? rom code protect address in qzrom version (address ffdb 16 ) address ffdb 16 as reserved rom area in the qzrom version is rom code protect address. ?00 16 ? or ?fe 16 ? is written into this address when selecting the protect bit write by using a serial programmer and selecting protect enabled for writing shipment by renesas technology corp. when ?00 16 ? or ?fe 16 ? is set to the rom code protect address, th e protect function is enabled, so that reading or writing from/to the corresponding area is disabled by a serial programmer. as for the qzrom product in blan k, the rom code is protected by selecting the protect bit wr ite at rom writing with a serial programmer. the protect can be performed, di viding twice. the protect area 1 is from the beginning address of rom to address ?efff 16 ?. as for the qzrom product sh ipped after writing, ?00 16 ? (protect enabled to all area), ?fe 16 ? (protect enabled to the protect area 1) or ?ff 16 ? (protect disabled) is written into the rom code protect address when renesas technology corp. performs writing. the writing of ?00 16 ?, ?fe 16 ? or ?ff 16 ? can be selected as rom option setup (?mask option? written in the mask file converter) when ordering. for the rom code protect in the flash memory version, refer to the ?flash memory mode?. ? after a reset, the contents of ram are undefined. make sure to set the initial value before use. ? when renesas ships qzrom write products, we write rom option data* specified by the mask file converter mm to the rom code protect addre ss. therefore, set ff 16 to the rom code protect address in rom da ta regardless of the presence or absence of a protect. when data other than ff 16 is set, we may ask that the rom da ta be submitted again. * rom option data: mask option noted in mm fig. 9 memory map diagram reserved area sfr area 0ff0 16 1000 16 sfr area interrupt vector area rom area reserved rom area (128 bytes) 0100 16 0000 16 0040 16 0840 16 ff00 16 ffdc 16 fffe 16 ffff 16 zero page special page ram area ram size (bytes) address xxxx 16 192 256 384 512 640 768 896 1024 1536 2048 xxxx 16 00ff 16 013f 16 01bf 16 023f 16 02bf 16 033f 16 03bf 16 043f 16 063f 16 083f 16 rom size (bytes) address yyyy 16 address zzzz 16 4096 8192 12288 16384 20480 24576 28672 32768 36864 40960 45056 49152 53248 57344 61440 f000 16 e000 16 d000 16 c000 16 b000 16 a000 16 9000 16 8000 16 7000 16 6000 16 5000 16 4000 16 3000 16 2000 16 1000 16 f080 16 e080 16 d080 16 c080 16 b080 16 a080 16 9080 16 8080 16 7080 16 6080 16 5080 16 4080 16 3080 16 2080 16 1080 16 yyyy 16 zzzz 16 reserved rom area ram rom protect area 1 efff 16 ffdb 16 reserved rom area (rom code protect) not used 0fd0 16 reserved area ( 2 ) note 1 : this area is available in the flash memory version only. 2 : rom correction vectors are assigned. as for the details, refer to the ?rom correction function?. 3 : in the flash memory version, programming and erase operations can be performed to reserved rom areas. note that their areas are different from those in the qzrom version. ( 2 ) reserved rom area (id code) ffd4 16 ( 1 ) sfr area 0fef 16 0fe0 16 ( 1 ) lcd display ram area 004c 16
rev.3.02 apr 10, 2008 page 17 of 131 rej03b0177-0302 38d2 group fig. 10 memory map of spec ial function register (sfr) 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 0010 16 0011 16 0012 16 0013 16 0014 16 0015 16 0016 16 0017 16 0018 16 0019 16 001a 16 001b 16 001c 16 001d 16 001e 16 001f 16 0020 16 0021 16 0022 16 0023 16 0024 16 0025 16 0026 16 0027 16 0028 16 0029 16 002a 16 002b 16 002c 16 002d 16 002e 16 002f 16 0030 16 0031 16 0032 16 0033 16 0034 16 0035 16 0036 16 0037 16 0038 16 0039 16 003a 16 003b 16 003c 16 003d 16 003e 16 003f 16 cpu mode register 2 (cpum2) rrf register (rrfr) lcd mode register (lm) lcd power control register (vlcon) ad control register (adcon) ad conversion register (low-order) (adl) ad conversion register (high-order) (adh) port p0 (p0) port p0 direction register (p0d) port p1 (p1) port p1 direction register (p1d) port p2 (p2) port p2 direction register (p2d) port p3 (p3) port p3 direction register (p3d) port p4 (p4) port p4 direction register (p4d) port p5 (p5) port p5 direction register (p5d) port p6 (p6) port p6 direction register (p6d) oscillation output control register (oscout) timer x (low-order) (txl) timer x (high-order) (txh) timer x (extension) (txex) timer x mode register (txm) timer x control register 1 (txcon1) timer x control register 2 (txcon2) compare register 1 (low-order) (comp1l) compare register 1 (high-order) (comp1h) compare register 2 (low-order) (comp2l) compare register 2 (high-order) (comp2h) compare register 3 (low-order) (comp3l) compare register 3 (high-order) (comp3h) timer y (low-order) (tyl) timer y (high-order) (tyh) timer y mode register (tym) timer y control register (tycon) interrupt edge selection register (intedge) cpu mode register (cpum) interrupt request register 1 (ireq1) interrupt request register 2 (ireq2) interrupt control register 1 (icon1) interrupt control register 2 (icon2) transmit/receive buffer register 1 (tb1/rb1) serial i/o1 status register (sio1sts) serial i/o1 control register (sio1con) uart1 control register (uart1con) baud rate generator 1 (brg1) transmit/receive buffer register 2 (tb2/rb2) serial i/o2 status register (sio2sts) serial i/o2 control register (sio2con) timer 1 (t1) timer 2 (t2) timer 3 (t3) timer 4 (t4) pwm01 register (pwm01) timer 12 mode register (t12m) timer 34 mode register (t34m) timer 1234 mode register (t1234m) timer 1234 frequency division selection register (pre1234) watchdog timer control register (wdtcon) rom correction address 1 high-order register (rca1h) rom correction address 1 low-order register (rca1l) rom correction address 2 high-order register (rca2h) rom correction address 2 low-order register (rca2l) rom correction enable register (rcr) reserved reserved reserved 0ff0 16 0ff1 16 0ff2 16 0ff3 16 0ff4 16 0ff5 16 0ff6 16 0ff7 16 0ff8 16 0ff9 16 0ffa 16 0ffb 16 0ffc 16 0ffd 16 0ffe 16 0fff 16 pull register (pull) uart2 control register (uart2con) baud rate generator 2 (brg2) clock output control register (ckout) segment output disable register 0 (seg0) segment output disable register 1 (seg1) segment output disable register 2 (seg2) key input control register (kic) note 1 : the blanks are reserved. do not write data to these areas. 2 : no memory access is allowed to the blank areas within the sfrs. 3 : addresses 0fe0 16 to 0fef 16 are available in the flash memory version only. 0fe0 16 0fe1 16 0fe2 16 0fe3 16 0fe4 16 0fe5 16 0fe6 16 0fe7 16 0fe8 16 0fe9 16 0fea 16 0feb 16 0fec 16 0fed 16 0fee 16 0fef 16 flash memory control register 0 (fmcr0) flash memory control register 1 (fmcr1) flash memory control register 2 (fmcr2) reserved reserved reserved reserved reserved reserved reserved reserved reserved reserved reserved reserved reserved ( 1 ) ( 1 ) ( 1 ) ( 1 ) ( 1 ) ( 1 ) ( 1 ) ( 1 ) ( 1 ) ( 1 ) ( 1 ) ( 1 ) ( 1 ) ( 1 ) ( 1 ) ( 1 )
rev.3.02 apr 10, 2008 page 18 of 131 rej03b0177-0302 38d2 group i/o ports ? direction registers the i/o ports p0 ? p6 have direction registers which determine the input/output direction of each individual pin. each bit in a direction register corresponds to one pin, each pin can be set to be input port or output port. when ?0? is written to the bit of the direction register, the corresponding pin becomes an input pin. as for ports p0 ? p2, when ?1? is written to the bit of the direction register and the segment output disable register , the corresponding pin becomes an output pin. as for ports p3 ? p6, when ?1? is written to the bit of the direction register, the corresponding pin becomes an output pin. if data is read from a pin set to output, the value of the port latch is read, not the value of the pin itself. however, when peripheral output (rtp 1 , rtp 0 , t xout1 , t 4out , t 3out , t 2out /ckout, o out0 , and o out1 ) is selected, the output value is read. pins set to input are floating. if a pin set to input is written to, only the port output latch is written to and the pin remains floating. ? pull-up control each individual bit of ports p0 ? p2 can be pulled up with a program by setting direction regi sters and segment output disable registers 0 to 2 (addresses 0ff4 16 to 0ff6 16 ). the pin is pulled up by setting ?0? to the direction register and ?1? to the segment output disable register. by setting the pull register (addresses 0ff0 16 ), ports p3 ? p6 can control pull-up with a program. however, the contents of pull register do not affect ports programmed as the output ports. fig. 11 structure of ports p0 to p2 fig. 12 structure of pull register and segment output disable register segment output disable register direction register input port no pull-up input port pull-up segment output port output ?0? ?0? ?1? ?1? initial state p0 0 pull-up p0 1 pull-up p0 2 pull-up p0 3 pull-up p0 4 pull-up p0 5 pull-up p0 6 pull-up p0 7 pull-up segment output disable register 0 (seg0 : address 0ff4 16 ) b7 b0 notes 1 : the pull register and segment output disable register affect only ports programmed as the input ports. 2 : when the v l pin input selection bit (vlsel) of the lcd power control register (address 0014 16 ) is ?1?, settings of p2 6 and p2 7 are invalid. pull register (pull : address 0ff0 16 ) b7 b0 p3 0 ? p3 3 pull-up p3 4 ? p3 7 pull-up p4 0 ? p4 3 pull-up p4 4 ? p4 7 pull-up p5 0 ? p5 3 pull-up p5 4 ? p5 7 pull-up p6 0 ? p6 2 pull-up not used (return ?0? when read) p1 0 pull-up p1 1 pull-up p1 2 pull-up p1 3 pull-up p1 4 pull-up p1 5 pull-up p1 6 pull-up p1 7 pull-up segment output disable register 1 (seg1 : address 0ff5 16 ) b7 b0 p2 0 pull-up p2 1 pull-up p2 2 pull-up p2 3 pull-up p2 4 pull-up p2 5 pull-up p2 6 pull-up p2 7 pull-up segment output disable register 2 (seg2 : address 0ff6 16 ) b7 b0 0 : no pull-up 1 : pull-up 0 : no pull-up 1 : pull-up 0 : no pull-up 1 : pull-up 0 : no pull-up 1 : pull-up
rev.3.02 apr 10, 2008 page 19 of 131 rej03b0177-0302 38d2 group notes 1: for details of how to use double/triple function ports as function i/o ports, refer to the applicable sections. 2: make sure that the i nput level at each pin is either 0 v or v cc during execution of the stp instruction. when an input level is at an intermedia te potential, a current will flow from v cc to v ss through the input-stage gate. table 8 list of i/o port function pin name input/output i/o format non-port function related sfrs ref. no. p0 0 /seg 0 /(kw 4 ) ? p0 3 /seg 3 /(kw 7 ) port p0 input/output, individual bits cmos compatible input level cmos 3-state output lcd segment output key input (key-on wakeup) interrupt input segment output disable register 0 (1) p0 4 /seg 4 ? p0 7 /seg 7 (2) p1 0 /seg 8 ? p1 7 /seg 15 port p1 input/output, individual bits cmos compatible input level cmos 3-state output segment output disable register 1 p2 0 /seg 16 ? p2 5 /seg 21 port p2 input/output, individual bits cmos compatible input level cmos 3-state output segment output disable register 2 p2 6 /seg 22 /v l1 p2 7 /seg 23 /v l2 lcd power input p3 0 /s rdy2 /(led 0 ) p3 1 /s clk2 /(led 1 ) p3 2 /t x d 2 /(led 2 ) p3 3 /r x d 2 /(led 3 ) port p3 input/output, individual bits cmos compatible input level cmos 3-state output serial i/o2 function i/o pull register serial i/o2 control register serial i/o2 status register uart2 control register (3) (4) (5) (6) p3 4 /int 2 /(led 4 ) external interrupt input pull register interrupt edge selection register (7) p3 5 /t xout1 /(led 5 ) timer x output 1 pull register (8) p3 6 /t 2out/ ckout /(led 6 ) timer 2 output clock output timer x mode register timer 12 mode register clock output control register (9) p3 7 /cntr 0 /t xout2 /(led 7 ) timer x function input timer x output 2 pull register timer x mode register (10) p4 0 /o out0 /an 0 p4 1 /o out1 /an 1 port p4 input/output, individual bits cmos compatible input level cmos 3-state output oscillation external output pins pull register ad control register oscillation output control register (13) p4 2 /an 2 /adkey a/d conversion input pull register (11) p4 3 /an 3 ? p4 5 /an 5 ad control register (12) p4 6 /rtp 0 /an 6 p4 7 /rtp 1 /an 7 real time port function output pull register ad control register timer y mode register (13) p5 0 /int 0 p5 1 /int 1 port p5 input/output, individual bits cmos compatible input level cmos 3-state output external interrupt input pull register interrupt edge selection register (7) p5 2 /t 3out /pwm 0 p5 3 /t 4out /pwm 1 timer 3 output timer 4 output pwm output pull register timer 34 mode register (9) p5 4 /r x d 1 /(kw 0 ) p5 5 /t x d 1 /(kw 1 ) p5 6 /s clk1 /(kw 2 ) p5 7 /s rdy1 /(kw 3 ) serial i/o1 function i/o key input (key-on wakeup) interrupt input pull register serial i/o1 control register serial i/o1 status register uart1 control register (14) (15) (16) (17) p6 0 /cntr 1 port p6 input/output, individual bits cmos compatible input level cmos 3-state output timer y function input pull register timer y mode register (7) p6 1 /x cin sub-clock oscillation circuit pull register (18) p6 2 /x cout cpu mode register (19) com 0 ? com 3 common output lcd common output lcd mode register (20)
rev.3.02 apr 10, 2008 page 20 of 131 rej03b0177-0302 38d2 group fig. 13 port block diagram (1) (1) ports p0 0 -p0 3 (6) port p3 3 (5) port p3 2 (3) port p3 0 data bus serial i/o enable bit transmit enable bit serial i/o output p32/txd2 p-channel output disable bit port latch direction register pull-up control serial i/o ready output data bus port latch serial i/o mode selection bit serial i/o enable bit s rdy2 output enable bit direction register pull-up control pull-up control direction register data bus serial i/o enable bit receive enable bit serial i/o input port latch (4) port p3 1 serial i/o synchronous clock selection bit data bus serial i/o clock output serial i/o clock input serial i/o mode selection bit serial i/o enable bit port latch direction register serial i/o enable bit pull-up control (2) ports p0 4 -p0 7 , p1, p2 segment output disable bit direction register data bus port latch v l2 /v l3 v l1 /v ss key input control key-on wakeup interrupt input segment data segment output disable bit direction register data bus port latch lcd power input (v l1 ,v l2 ) only for p2 6 , p2 7 v l2 /v l3 v l1 /v ss segment data segment output disable bit segment output disable bit
rev.3.02 apr 10, 2008 page 21 of 131 rej03b0177-0302 38d2 group fig. 14 port block diagram (2) (12) ports p4 3 -p4 5 analog input pin selection bit a-d conversion input data bus port latch direction register pull-up control (14) port p5 4 (7) ports p3 4 , p5 0 , p5 1 , p6 0 data bus direction register port latch pull-up control cntr 1 interrupt input int 0 -int 2 interrupt input (8) port p3 5 port latch data bus pulse output mode timer x output direction register pull-up control direction register data bus serial i/o enable bit receive enable bit port latch pull-up control serial i/o input key-on wakeup interrupt input key input control (9) ports p3 6 , p5 2 , p5 3 port latch data bus port/timer output selection timer output/pwm output timer output/system clock output direction register pull-up control (13) ports p4 0 , p4 1 , p4 6 , p4 7 data bus port latch oscillation output control bit/ real time control bit direction register pull-up control analog input pin selection bit a-d conversion input oscillation output/ data for real time port (10) ports p3 7 data bus direction register port latch pull-up control cntr 0 interrupt input timer output a-d conversion input data bus port latch direction register pull-up control (11) ports p4 2 adkey enable bit analog input pin selection bit port/timer output selection
rev.3.02 apr 10, 2008 page 22 of 131 rej03b0177-0302 38d2 group fig. 15 port block diagram (3) (20) com 0 -com 3 v l3 v l2 v l1 v ss gate input signal of each gate depends on the duty ratio and bias values. (17) port p5 7 serial i/o ready output data bus port latch serial i/o mode selection bit serial i/o enable bit s rdy1 output enable bit direction register pull-up control key-on wakeup interrupt input key input control (19) port p6 2 data bus port latch direction register xc oscillation enabled + pull-up control xc oscillation enabled port p6 1 oscillator xc oscillation enabled (18) port p6 1 data bus port latch direction register xc oscillation enabled sub-clock generation circuit input xc oscillation enabled + pull-up control (16) port p5 6 serial i/o synchronous clock selection bit data bus serial i/o clock output serial i/o mode selection bit serial i/o enable bit port latch direction register serial i/o enable bit pull-up control serial i/o clock input key-on wakeup interrupt input key input control (15) port p5 5 data bus serial i/o enable bit transmit enable bit serial i/o output p5 5 /txd1 p-channel output disable bit port latch direction register pull-up control key-on wakeup interrupt input key input control
rev.3.02 apr 10, 2008 page 23 of 131 rej03b0177-0302 38d2 group ? termination of unused pins ? termination of common pins i/o ports: select an input port or an output port and follow each processing method. in addition, it is recommended that related registers be overwritten periodically to prevent malfunctions, etc. output ports: open. input ports: if the input level be come unstable, through current flow to an input circuit, and the power supply current may increase. especially, when expe cting low consumption current (at stp or wit instruction execution etc.), pull-up or pull-down input ports to prevent through current (built-in resistor can be used). we recommend processing unused pins through a resistor which can secure i oh ( avg ) or i ol ( avg ). because, when an i/o port or a pin which have an output function is selected as an input port, it may operate as an output port by incorrect operation etc. table 9 termination of unused pins pin termination 1 termination 2 termination 3 p0 0 /seg 0 /(kw 4 ) ? p0 7 /seg 7 i/o port when selecting seg output, open. ? p1 0 /seg 8 ? p1 7 /seg 15 p2 0 /seg 16 ? p2 7 /seg 23 /v l2 p3 0 /s rdy2 /(led 0 ), p5 7 /s rdy1 /(kw 3 ) when selecting s rdy function, perform termination of output port. ? p3 1 /s clk2 /(led 1 ), p5 6 /s clk1 /(kw 2 ) when selecting external clock input, perform termination of input port. when selecting internal clock output, perform termination of output port. p3 2 /t x d 2 /(led 2 ), p5 5 /t x d 1 /(kw 1 ) when selecting txd function, perform termination of output port. ? p3 3 /r x d 2 /(led 3 ), p5 4 /r x d 1 /(kw 0 ) when selecting rxd function, perform termination of input port. ? p3 4 /int 2 /(led 4 ) when selecting int function, perform termination of input port. ? p3 5 /t xout1 /(led 5 ) when selecting t xout function, perform termination of output port. ? p3 6 /t 2out /ckout/(led 6 ) when selecting t 2out function or ckout function, perform termination of output port. ? p3 7 /cntr 0 /t xout2 /(led 7 ) when selecting t xout function, perform termination of output port. ? p4 0 /o out0 /an 0 , p4 1 /o out1 /an 1 when selecting an function, these pins can be opened. (a/d conversion result cannot be guaranteed.) when selecting oscillation output, perform termination of output port. p4 2 /an 2 /adkey when selecting adkey function, pull-up this pin through a resistor. p4 3 /an 3 ? p4 7 /rtp 1 /an 7 ? p5 0 /int 0 , p5 1 /int 1 when selecting int function, perform termination of input port. ? p5 2 /t 3out /pwm 0 , p5 3 /t 4out /pwm 1 when selecting pwm, t 3out , or t 4out function, perform termination of output port. ? p6 0 /cntr 1 when selecting cntr input function, perform termination of input port. ? p6 1 /x cin , p6 2 /x cout do not select x cin -x cout oscillation function by program. ? v l3 set the v l3 connect bit to ?1? and apply a vcc level voltage to v l3 pin. set the v l3 connect bit to ?0? and leave the v l3 pin open. ? com 0 ? com 3 open ?? avss connect to vss ?? v ref connect to vcc ?? x in when only on-chip oscillator is used, connect to v cc through a resistor. ?? x out when external clock is input or when only on-chip oscillator is used, open. ??
rev.3.02 apr 10, 2008 page 24 of 131 rej03b0177-0302 38d2 group interrupts the 38d2 group interrupts are vector interrupts with a fixed priority scheme, and generated by 16 sources among 18 sources: 6 external, 11 intern al, and 1 software. the interrupt sources, vector addresses (1) , and interrupt priority are shown in table 10. each interrupt except the brk instruction interrupt has the interrupt request bit and the interr upt enable bit. these bits and the interrupt disable flag (i flag) control the acceptance of interrupt request s. figure 16 shows an interrupt control diagram. an interrupt requests is accept ed when all of the following conditions are satisfied: ? interrupt disable flag ................................ ?0? ? interrupt request bit .................................. ?1? ? interrupt enable bit ................................... ?1? though the interrupt priority is determined by hardware, priority processing can be performed by software using the above bits and flag. notes 1:vector addresses contain inte rrupt jump destination addresses. 2:reset function in the same way as an interrupt with the highest priority. table 10 interrupt vector addresses and priority interrupt source priority vector addresses (1) interrupt request generating conditions remarks high low reset (2) 1fffd 16 fffc 16 at reset non-maskable int 0 2fffb 16 fffa 16 at detection of eith er rising or falling edge of int 0 input external interrupt (active edge selectable) int 1 3fff9 16 fff8 16 at detection of eith er rising or falling edge of int 1 input external interrupt (active edge selectable) int 2 4fff7 16 fff6 16 at detection of eith er rising or falling edge of int 2 input valid when int 2 interrupt is selected external interrupt (active edge selectable) key input (key-on wakeup) at falling of ports p0 0 ? p0 3 , p5 4 ? p5 7 input logical level and valid when key input interrupt is selected external interrupt (falling valid) cntr 0 5fff5 16 fff4 16 at detection of eith er rising or falling edge of cntr 0 input external interrupt (active edge selectable) timer x 6 fff3 16 fff2 16 at timer x underflow timer 1 7 fff1 16 fff0 16 at timer 1 underflow valid when timer 1 interrupt is selected timer 2 8 ffef 16 ffee 16 at timer 2 underflow valid when timer 2 interrupt is selected timer 3 9 ffed 16 ffec 16 at timer 3 underflow valid when timer 3 interrupt is selected timer 4 10 ffeb 16 ffea 16 at timer 4 underflow valid when timer 4 interrupt is selected serial i/o1 receive 11 ffe9 16 ffe8 16 at completion of serial i/o1 data receive v alid only when serial i/o1 is selected serial i/o1 transmit 12 ffe7 16 ffe6 16 at completion of serial i/o1 transmit shift or transmit buffer is empty valid only when serial i/o1 is selected serial i/o2 receive 13 ffe5 16 ffe4 16 at completion of serial i/o2 data receive v alid only when serial i/o2 is selected serial i/o2 transmit 14 ffe3 16 ffe2 16 at completion of serial i/o2 data transmit shift or transmit buffer is empty valid only when serial i/o2 is selected timer y 15 ffe1 16 ffe0 16 at timer y underflow cntr 1 at detection of eith er rising or falling edge of cntr 1 input external interrupt (active edge selectable) a/d conversion 16 ffdf 16 ffde 16 at completion of a/d conversion valid when a/d interrupt is selected brk instruction 17 ffdd 16 ffdc 16 at brk instruction execution non-maskable software interrupt
rev.3.02 apr 10, 2008 page 25 of 131 rej03b0177-0302 38d2 group fig. 16 interrupt control ? interrupt disable flag the interrupt disable flag is as signed to bit 2 of the processor status register. this flag contro ls the acceptance of all interrupt requests except for the brk instruction. when this flag is set to ?1?, the acceptance of interrupt requests is disabled. when it is set to ?0?, acceptance of interrupt requests is enabled. this flag is set to ?1? with the sei instruc tion and set to ?0? with the cli instruction. when an interrupt request is accepted, the contents of the processor status register are pu shed onto the stack while the interrupt disable flag remains set to ?0?. subsequently, this flag is automatically set to ?1? and multiple interrupts are disabled. to use multiple interrupts, set this flag to ?0? with the cli instruction within the in terrupt processing routine. the contents of the processor stat us register are popped off the stack with the rti instruction. ? interrupt request bits once an interrupt request is generate d, the corresponding interrupt request bit is set to ?1? and remains ?1? until the request is accepted. when the request is accepted, this bit is automatically set to ?0?. each interrupt request bit can be set to ?0?, but cannot be set to ?1?, by software. ? interrupt enable bits the interrupt enable bits control the acceptance of the corresponding interrupt requests. wh en an interrupt enable bit is set to ?0?, the acceptance of th e corresponding interrupt request is disabled. if an interrupt reque st occurs in this condition, the corresponding interrupt request bit is set to ?1?, but the interrupt request is not accepted. when an in terrupt enable bit is set to ?1?, acceptance of the corresponding interrupt request is enabled. each interrupt enable bit can be set to ?0? or ?1? by software. the interrupt enable bit for an unused interrupt should be set to ?0?. ? interrupt source selection any of the following combinati ons can be selected by the interrupt edge selection register (003a 16 ). ?int 2 or key input ? timer y or cntr 1 interrupt request bit interrupt enable bit interrupt disable flag (i) brk instruction reset interrupt acceptance
rev.3.02 apr 10, 2008 page 26 of 131 rej03b0177-0302 38d2 group fig. 17 structure of interrupt-related registers int 0 interrupt request bit int 1 interrupt request bit int 2 interrupt request bit key input interrupt request bit cntr 0 interrupt request bit timer x interrupt request bit timer 1 interrupt request bit timer 2 interrupt request bit timer 3 interrupt request bit interrupt request register 1 (ireq1 : address 003c 16 ) int 0 interrupt enable bit int 1 interrupt enable bit int 2 interrupt enable bit key input interrupt enable bit cntr 0 interrupt enable bit timer x interrupt enable bit timer 1 interrupt enable bit timer 2 interrupt enable bit timer 3 interrupt enable bit timer 4 interrupt request bit serial i/o1 receive interrupt request bit serial i/o1 transmit interrupt request bit serial i/o2 receive interrupt request bit serial i/o2 transmit interrupt request bit timer y interrupt request bit cntr 1 interrupt request bit ad conversion interrupt request bit not used (returns ?0? when read) 0 : no interrupt request issued 1 : interrupt request issued timer 4 interrupt enable bit serial i/o1 receive interrupt enable bit serial i/o1 transmit interrupt enable bit serial i/o2 receive interrupt enable bit serial i/o2 transmit interrupt enable bit timer y interrupt enable bit cntr 1 interrupt enable bit ad conversion interrupt enable bit not used (do not write to ?1?.) interrupt control register 2 (icon2 : address 003f 16 ) 0 : interrupts disabled 1 : interrupts enabled 0 : int 2 interrupt 1 : key input interrupt interrupt control register 1 (icon1 : address 003e 16 ) interrupt request register 2 (ireq2 : address 003d 16 ) int0 interrupt edge selection bit int1 interrupt edge selection bit int2 interrupt edge selection bit int2/key input interrupt switch bit timer y/cntr 1 interrupt switch bit not used (do not write to ?1?.) not used (return ?0? when read) interrupt edge selection register (intedge : address 003a 16 ) 0 : falling edge active 1 : rising edge active 0 : timer y interrupt 1 : cntr 1 interrupt b7 b0 b7 b0 b7 b0 b7 b0 b7 b0
rev.3.02 apr 10, 2008 page 27 of 131 rej03b0177-0302 38d2 group ? interrupt request generation, acceptance, and handling interrupts have the following three phases. (i) interrupt request generation an interrupt request is gene rated by an interrupt source (external interrupt signal input, timer underflow, etc.) and the corresponding request bit is set to ?1?. (ii) interrupt request acceptance based on the interrupt acceptance timing in each instruction cycle, the interrupt control circuit determines acceptance conditions (interrupt request b it, interrupt enable bit, and interrupt disable flag) and in terrupt priority levels for accepting interrupt requests. when two or more interrupt requests are generated simultan eously, the highest priority interrupt is accepted. the valu e of interrupt request bit for an unaccepted interrupt remains the same and acceptance is determined at the next inte rrupt acceptance timing point. (iii) handling of acce pted interrupt request the accepted interrupt request is processed. figure 18 shows the time up to ex ecution in the interrupt routine, and figure 19 shows the interrupt sequence. figure 20 shows the timing of interrupt request generation, interrupt request bi t, and interrupt re quest acceptance. ? interrupt handling execution when interrupt handlin g is executed, the following operations are performed automatically. (1) once the currently executing instruction is completed, an interrupt request is accepted. (2) the contents of the program counters and the processor status register at this point are pushed onto the stack area in order from 1 to 3. 1. high-order bits of program counter (pch) 2. low-order bits of program counter (pcl) 3. processor status register (ps) (3) concurrently with the push operation, the jump address of the corresponding interrupt (the start address of the interrupt processing routine) is transferred from the interrupt vector to the program counter. (4) the interrupt reque st bit for the corresponding interrupt is set to ?0?. also, the interrupt disable flag is set to ?1? and multiple interrupts are disabled. (5) the interrupt routine is executed. (6) when the rti instruction is executed, the contents of the registers pushed onto the stack area are popped off in the order from 3 to 1. then, the routine that was before running interrupt processing resumes. as described above, it is necess ary to set the stack pointer and the jump address in the vect or area corresponding to each interrupt to execute the interrupt processing routine. fig. 18 time up to execution in interrupt routine fig. 19 interrupt sequence 7 cycles interrupt request generated interrupt request acceptance interrupt routine starts interrupt sequence * 0 to 16 cycles 7 to 23 cycles * when executing div instruction main routine stack push and vector fetch interrupt handling routine sync rd wr push onto stack vector fetch address bus data bus execute interrupt routine pc s,sps s-1,sps s-2,sps b l b h a l ,a h not used pc h pc l ps a l a h sync : cpu operation code fetch cycle (this is an internal signal that cannot be observed from the external unit.) bl, bh: vector address of each interrupt al, ah: jump destination address of each interrupt sps : ?00 16 ? or ?01 16 ? ([sps] is a page selected by the stack page selection bit of cpu mode register.)
rev.3.02 apr 10, 2008 page 28 of 131 rej03b0177-0302 38d2 group the interrupt request bit may be set to ?1? in the following cases. ? when setting the external interrupt active edge related bits: int 0 interrupt edge selection bit (bit 0 of interrupt edge selection register (address 003a 16 )) int 1 interrupt edge selection bit (bit 1 of interrupt edge selection register) int 2 interrupt edge selection bit (bit 2 of interrupt edge selection register) cntr 0 activate edge switch bit (bits 6 and 7 of timer x control register 1 (address 002e 16 )) cntr 1 activate edge switch bit (bits 6 of timer y mode register (address 0038 16 )) ? when switching the interrupt so urces of an interrupt vector address where two or more in terrupt sources are assigned related bit: timer y/cntr 1 interrupt switch bit (bit 3 of interrupt e dge selection register) if it is not necessary to generate an interrupt synchronized with these settings, take the following sequence. (1) set the corresponding enable bit to ?0? (disabled). (2) set the interrupt edge select ion bit (the acti ve edge switch bit) or the interrupt source bit. (3) set the corresponding interrupt request bit to ?0? after one or more instructions have been executed. (4) set the corresponding interrupt enable bit to ?1? (enabled). fig. 20 timing of interrupt request generation, interrupt request bit, and interrupt acceptance t1 (1) the interrupt re quest bit for an interrupt request generated during period 1 is set to ?1? at timing point ir1. (2) the interrupt request bit for an interrupt request generated during period 2 is set to ?1? at timing point ir1 or ir2. the timing point at which the bit is set to ?1? varies depending on conditions. when two or more interrupt requests are generated during the period 2, each request bit may be set to ?1? at timing point ir1 or ir2 separately. t1 t2 t3 : interrupt acceptance timing points ir1 ir2 : timings points at which the interrupt request bit is set to ?1?. note : period 2 indicates the last cycle during one instruction cycle. ir1 t2 sync ir2 t3 12 internal clock instruction cycle push onto stack vector fetch instruction cycle
rev.3.02 apr 10, 2008 page 29 of 131 rej03b0177-0302 38d2 group ? key input interrupt (key-on wake-up) a key input interrupt re quest is generated by detecting the falling edge from any pin of ports p0 0 ? p0 3 , p5 4 ? p5 7 that have been set to input mode. in other words, it is generated when and of input level goes from ?1? to ?0?. an example of using a key input interrupt is shown in figure 21 , where an interrupt request is generated by pressing one of the ke ys consisted as an active-low key matrix which inputs to ports p5 4 ? p5 7 . fig. 21 connection example when using key input interrupt ? ? ? ? ? ? ? ? ?? ?? ?? ?? ?? ?? ?? ?? port p5 4 latch port p5 4 direction register = ?0? port p5 5 latch port p5 5 direction register = ?0? port p5 6 latch port p5 6 direction register = ?0? port p5 7 latch port p5 7 direction register = ?0? port p0 0 latch port p0 0 direction register = ?1? port p0 1 latch port p0 1 direction register = ?1? port p0 2 latch port p0 2 direction register = ?1? port p0 3 latch port p0 3 direction register = ?1? p5 4 input p5 5 input p5 6 input p5 7 input p0 0 output p0 1 output p0 2 output p0 3 output pull register bit 5 = ?1? port p0 input reading circuit key input interrupt request port pxx ?l? level output ? p-channel transistor for pull-up ?? cmos output buffer port p5 input reading circuit key input control register = ?1? key input control register = ?1? key input control register = ?1? key input control register = ?1? key input control register = ?1? key input control register = ?1? key input control register = ?1? key input control register = ?1? segment output disable register 0 bit 3 = ?1? segment output disable register 0 bit 2 = ?1? segment output disable register 0 bit 1 = ?1? segment output disable register 0 bit 0 = ?1?
rev.3.02 apr 10, 2008 page 30 of 131 rej03b0177-0302 38d2 group a key input interrupt is contro lled by the key input control register and port direction regist ers. when the key input interrupt is enabled, set ?1? to the key input control register. a key input of any pin of ports p0 0 ? p0 3 , p5 4 ? p5 7 that have been set to input mode is accepted. fig. 22 structure of key input control register p5 4 key input control bit p5 5 key input control bit p5 6 key input control bit p5 7 key input control bit p0 0 key input control bit p0 1 key input control bit p0 2 key input control bit p0 3 key input control bit b7 key input control register (kic : address 0ff7 16 ) 0 : key input interrupt disabled 1 : key input interrupt enabled b0
rev.3.02 apr 10, 2008 page 31 of 131 rej03b0177-0302 38d2 group timers 8-bit timer the 38d2 group has four built-in 8-bit timers: timer 1, timer 2, timer 3, and timer 4. each timer has the 8-bit timer latch. all timers are down- counters. when the timer reaches ?00 16 ?, the contents of the timer latch is reloaded into the timer with the ne xt count pulse. in this mode, the interrupt request bit corresponding to that timer is set to ?1?. the count can be stopped by setti ng the stop bit of each timer to ?1?. fig. 23 timer 1-4 block diagram timer 1 latch (8) timer 1 (8) timer 2 latch (8) timer 2 (8) timer 3 latch (8) timer 3 (8) timer 4 latch (8) timer 4 (8) timer 1 interrupt request timer 2 interrupt request timer 3 interrupt request timer 4 interrupt request x cin data bus timer 1 count stop bit 10 bit pwm1 circuit 1/2 q q s t timer 4 operating mode selection bit t 4out output edge switch bit p5 3 latch timer 4 output selection bit p5 3 direction register p5 3 /pwm 1 / t 4out 10 bit pwm0 circuit 1/2 q q s t timer 3 operating mode selection bit t 3out output edge switch bit p5 2 latch timer 3 output selection bit timer 3 output selection bit p5 2 direction register p5 2 /pwm 0 / t 3out ?00? ?01? ?10? ?00? ?01? ?1? ?0? ?01? ?10? ?00? ?0? ?1? ?1? ?0? ?0? ?1? ?1? ?0? clock for timer 1 clock for timer 2 clock for timer 3 clock for timer 4 timer 1 timer 2 timer 3 timer 4 frequency division selection bits (2 bits for each timer) c l o c k f o r t i m e r 1 c l o c k f o r t i m e r 2 c l o c k f o r t i m e r 3 c l o c k f o r t i m e r 4 8 the following values can be selected the clock for timer; 1/1,1/2,1/16,1/256 frequency divider 1/2 q q s t t 2out output edge switch bit timer 2 output selection bit ?0? ?1? p3 6 direction register p3 6 /t 2out /ckout p3 6 latch timer 2 output selection bit p3 6 clock output control bit system clock ?1? ?0? ?10? timer y output timer 3 write control bit pwm01 register (2) pwm01 register (2) timer 4 write control bit timer 2 write control bit timer 1 count source selection bits timer 2 count source selection bits timer 2 count stop bit timer 3 count source selection bit timer 3 count stop bit timer 4 count source selection bits timer 4 count stop bit timer 4 output selection bit source source: represents the oscillation frequency of x in input in the frequency/2, 4 or 8 mode, on-chip oscillator divide d by 4 in the on-chip oscillator mode, and sub-clock in the low-speed mode. ?11? f(x in ) (note)
rev.3.02 apr 10, 2008 page 32 of 131 rej03b0177-0302 38d2 group ? frequency divider for timer timer 1, timer 2, timer 3 and timer 4 have the frequency divider for the count source. the count source of the frequency divider is switched to x in , x cin , or the on-chip oscillator oco divided by 4 in the on-chip oscillator mode by the cpu mode register. the frequency divider is controlled by each timer division ratio selection bit. the division ratio can be selected from as follows; 1/1, 1/2, 1/16, 1/256 of f(x in ), f(x cin ) or f(oco)/4. switch the frequency division or count source* while the timer count is stopped. *this also applies when the frequency divider output is selected as the timer count source and th e count source is switched in conjunction with a transition between operating modes (on- chip oscillator mode, x in mode, or low-speed mode). be careful when changi ng settings in the cp u mode register. ? timer 1, timer 2 the count source for timer 1 and timer 2 can be set using the timer 12 mode register. x cin may be selected as the count source. if x cin is selected, c ount operation is possible regardless of whether or not the x in input oscillator or the on-chip oscillator is operating. in addition, the time r 12 mode register can be used to output from the p3 6 /t 2out pin a signal to invert the polarity every time timer 2 underflows. at reset, all bits of the timer 12 mode register are set to ?0?, timer 1 is set to ?ff 16 ?, and timer 2 is set to ?01 16 ?. when executing the stp instruction, previously set the wait time at return. ? timer 3, timer 4 the count sources of timer 3 an d timer 4 can be selected by setting the timer 34 mode register. also, by the timer 34 mode register, each time timer 3 or timer 4 underflows, the signal of which polarity is inverted can be output from p5 2 /t 3out pin or p5 3 /t 4out pin. ? timer 3 pwm 0 mode, timer 4 pwm 1 mode a pwm rectangular waveform corresponding to the 10-bit accuracy can be output from the p5 2 /pwm 0 pin and p5 3 /pwm 1 pin by setting the timer 34 mode register and pwm01 register (refer to figure 24). one output pulse is the short inte rval. four output pulses are the long interval. the ?n? is the va lue set in the timer 3 (address 0022 16 ) or the timer 4 (address 0023 16 ). the ?ts? is one period of timer 3 or timer 4 count source. ?h ? width of the short interval is obtained by n ts. however, in the long interval , ?h? width of output pulse is extended for ts which is set by the pwm01 register (address 0024 16 ). (1) timer 3 pwm 0 mode, timer 4 pwm 1 mode ? when pwm output is suspende d after starting pwm output, depending on the level of the output pulse at that time to resume an output, the delay of the one section of the short interval may be needed. stop at ?h?: no output delay stop at ?l?: output is delayed time of 256 ts ? in the pwm mode, the follows are performed every cycle of the long interval (4 256 ts). ? generation of timer 3, timer 4 interrupt requests ? update of timer 3, timer 4 (2) write to timer 2, timer 3, timer 4 when writing to the latch only, if the write timing to the reload latch and the underflow timing are almost the same, the value is set into the timer and the timer la tch at the same time. in this time, counting is stopped during writing to the reload latch. fig. 24 waveform of pwm0 and pwm1 output waveform of timer 3 pwm0 or timer 4 pwm1 n: setting value of timer 3 or timer 4 ts: one period of timer 3 count source or timer 4 count source pwm01 register (address 0024 16 ) : 2-bit value corresponding to pwm0 (bits 0, 1) or pwm1 (bits 2, 3) 256 t s 256 t s 256 t s 256 t s n ts n ts n ts n ts n ts n ts n ts n ts n ts n ts pwm01 register = ?00 2 ? pwm01 register = ?01 2 ? pwm01 register = ?10 2 ? pwm01 register = ?11 2 ? (n+1) ts (n+1) ts (n+1) ts (n+1) ts (n+1) ts (n+1) ts short interval short interval short interval short interval long interval 4 256 t s interrupt request interrupt request
rev.3.02 apr 10, 2008 page 33 of 131 rej03b0177-0302 38d2 group fig. 25 structure of timer 1 to timer 4 related registers timer 12 mode register (t12m: address 0025 16 ) timer 34 mode register (t34m: address 0026 16 ) timer 1234 mode register (t1234m: address 0027 16 ) timer 1234 frequency division selection register (pre1234: address 0028 16 ) pwm01 register (pwm01: address 0024 16 ) timer 1 frequency division selection bits b1b0 0 0 : 1/16 source 0 1 : 1/1 source 1 0 : 1/2 source 1 1 : 1/256 source timer 3 frequency division selection bits b5b4 0 0 : 1/16 source 0 1 : 1/1 source 1 0 : 1/2 source 1 1 : 1/256 source timer 1 count stop bit 0 : count operation 1 : count stop t 2out output edge switch bit 0 : start at ?l? output 1 : start at ?h? output timer 2 output selection bit (p3 6 ) 0 : i/o port 1 : timer 2 output timer 2 count source selection bits b5b4 0 0 : underflow of timer 1 0 1 : f(x cin ) 1 0 : frequency divider for timer 2 1 1 : not available timer 1 count source selection bits b3b2 0 0 : frequency divider for timer 1 0 1 : f(x cin ) 1 0 : underflow of timer y 1 1 : not available timer 2 count stop bit 0 : count operation 1 : count stop pwm0 set bits b1b0 0 0 : no extended 0 1 : extended once in four periods 1 0 : extended twice in four periods 1 1 : extended three times in four periods not used (returns ?0? when read) pwm1 set bits b3b2 0 0 : no extended 0 1 : extended once in four periods 1 0 : extended twice in four periods 1 1 : extended three times in four periods timer 2 frequency division selection bits b3b2 0 0 : 1/16 source 0 1 : 1/1 source 1 0 : 1/2 source 1 1 : 1/256 source timer 4 frequency division selection bits b7b6 0 0 : 1/16 source 0 1 : 1/1 source 1 0 : 1/2 source 1 1 : 1/256 source t 3out output edge switch bit 0 : start at ?l? output 1 : start at ?h? output not used (returns ?0? when read) timer 4 write control bit 0 : write data to both timer latch and timer 1 : write data to timer latch only timer 3 write control bit 0 : write data to both timer latch and timer 1 : write data to timer latch only timer 2 write control bit 0 : write data to both timer latch and timer 1 : write data to timer latch only timer 4 output selection bit (p5 3 ) 0 : i/o port 1 : timer 4 output timer 3 output selection bit (p5 2 ) 0 : i/o port 1 : timer 3 output t 4out output edge switch bit 0 : start at ?l? output 1 : start at ?h? output timer 3 count stop bit 0 : count operation 1 : count stop not used (returns ?0? when read) timer 4 operating mode selection bit 0 : timer mode 1 : pwm mode timer 3 operating mode selection bit 0 : timer mode 1 : pwm mode timer 4 count source selection bits b4b3 0 0 : frequency divider for timer 4 0 1 : underflow of timer 3 1 0 : underflow of timer 2 1 1 : f(x in ) timer 3 count source selection bit 0 : frequency divider for timer 3 1 : underflow of timer 2 timer 4 count stop bit 0 : count operation 1 : count stop b7 b0 b7 b0 b7 b0 b7 b0 b7 b0 note1: source indicates the followings: ?x in input in the frequency/2, 4, or 8 mode ?on-chip oscillator divided by 4 in the on-chip oscillator mode ?sub-clock in the low-speed mode (1)
rev.3.02 apr 10, 2008 page 34 of 131 rej03b0177-0302 38d2 group 16-bit timer read and write operation on 16 -bit timer must be performed for both high and low-order bytes. when reading a 16-bit timer, read the high-order byte first. wh en writing to a 16-bit timer, write the low-order byte first. the 16-bit timer cannot perform the correct operation when reading du ring the write operation, or when writing during the read operation. fig. 26 timer x block diagram data bus 1/2 1/4 frequency divider noise filter sampling clock selection bit ?1? ?0? timer x interrupt request timer x (high-order)(8) timer x (low-order)(8) timer x (high-order) latch (8) timer x (low-order) latch (8) equal ?000? ?001? ?010? ?011? ?101? pulse width measurement mode timer x count stop bit int 2 cntr 0 active edge switch bits timer x operating mode bits cntr 0 interrupt request ?100? extend latch (2) timer x write control bit timer 1 interrupt d q latch data for control of event counter window cntr 0 int 0 0 s delay time selection bits 4/f(x in ) ?00? ?01? ?10? ?11? 8/f(x in ) 16/f(x in ) noise filter (4 times same levels judgment) int 0 interrupt request count source selection bit xc in ?1? ?0? clock for timer x x in frequency divider timer x frequency division selection bits 2 both edges detection ?00? ?01? ?10? ?11? timer x output control bit 1 timer x output control bit 2 timer x operating mode bits ?010? delay circuit ?000? ?001? ?011? ?100? ?101? timer x operating mode bits ?010? compare register 3 (low-order)(8) compare register 3 (high-order)(8) compare register 1 (low-order)(8) compare register 1 (high-order)(8) compare register 2 (low-order)(8) compare register 2 (high-order)(8) q q t s pulse output mode timer x output 1 selection bit p3 5 latch p3 5 direction register p3 5 /t xout1 /(led 5 ) q q t r timer x output 1 edge switch bit ?0? ?1? igbt output mode pwm mode q q t r timer x output 2 selection bit p3 7 latch p3 7 direction register p3 7 /cntr 0 /t xout2 /(led 7 ) timer x output 2 edge switch bit ?0? ?1? extend counter (2) source source : represents the supply source of internal clock . x in input: in the frequency/2, 4 or 8 mode, internal on-chip oscillator divided by 4 in the on-chip oscillator mode, and sub clock in the low-speed mode. ?0? ?1? delay circuit 1/2 ?1? ?0? 2 trigger for igbt control bit trigger for igbt control bit int 1 edge selection edge selection * edge selection * edge detection
rev.3.02 apr 10, 2008 page 35 of 131 rej03b0177-0302 38d2 group ? frequency divider for timer each timer x and timer y have the frequency dividers for the count source. the count source of the frequency divider is switched to x in , x cin , or the on-chip oscillator oco divided by 4 in the on-chip oscillator mode by the cpu mode register. the division ratio of each timer can be controlled by each timer division ratio selection bit. the division ratio can be selected from as follows; 1/1, 1/2, 1/16, 1/256 of f(x in ), f(x cin ) or f(oco)/4. switch the frequency division or count source* while the timer count is stopped. *this also applies when the frequency divider output is selected as the timer count source and th e count source is switched in conjunction with a transition between operating modes (on- chip oscillator mode, x in mode, or low-speed mode). be careful when changi ng settings in the cp u mode register. ? timer x the count source for timer x can be set using the timer x mode register. x cin may be selected as the count source. if x cin is selected, count operation is possi ble regardless of whether or not the x in input oscillator or the on -chip oscillator is operating. the timer x operates as down-c ount. when the timer contents reach ?0000 16 ?, an underflow occurs at the next count pulse and the timer latch contents are reloaded. after that, the timer continues countdown. when the timer underflows, the interrupt request bit corresponding to th e timer x is set to ?1?. six operating modes can be selected for timer x by the timer x mode register and time r x control register. (1) timer mode the count source can be select ed by setting the timer x mode register. in this mode, timer x operates as the 18-bit counter by setting the timer x register (extension). (2) pulse output mode pulses of which polarity is inverted each time the timer underflows are output from the t xout1 pin. except for that, this mode operates just as in the timer mode. when using this mode, set the port sharing the t xout1 pin to output mode. (3) igbt output mode after dummy output from the t xout1 pin, count starts with the int 0 pin input as a trigger. in the case that the timer x output 1 active edge switch bit is ?0?, when the trigger is detected or the timer x underflows, ?h? is output from the t xout1 pin. and then, when the count value co rresponds with the compare register 1 value, the t xout1 output becomes ?l?. after noise is cleared by noise filters, judging continuous 4-time same levels with sampling clocks to be signals, the int 0 signal can use 4 types of delay time by a delay circuit. when using this mode, set the port sharing the int 0 pin to input mode and set the port sharing the pin used as t xout1 or t xout2 function to output mode. when the timer x output control b it 1 or 2 of the timer x control register is set to ?1?, the timer x count stop bit is fixed to ?1? forcibly by the interrupt signal of int 1 or int 2 . and then, the t xout1 output and t xout2 output can be set to ?l? forcibly at the same time that th e timer x stops counting. do not write ?1? to the timer x register (extension) when using the igbt output mode. (4) pwm mode igbt dummy output, an external trigger with the int 0 pin and output control with pins int 1 and int 2 are not used. except for those, this mode operates just as in the igbt output mode. the period of pwm waveform is specified by the timer x set value. in the case that the time r x output 1 active edge switch bit is ?0?, the ?h? interval is specified by the compare register 1 set value. in the case that the time r x output 2 active edge switch bit is ?0?, the ?h? interval is sp ecified by the compare registers 2 and 3 set values. when using this mode, set the port sharing the pin used as t xout1 or t xout2 function to output mode. do not write ?1? to the timer x register (extension) when using the pwm mode. (5) event counter mode the timer counts signals input through the cntr 0 pin. in this mode, timer x operates as the 18-bit counter by setting the timer x register (extension). when using this mode, set the port sharing the cntr 0 pin to input mode. in this mode, the window control can be performed by the timer 1 underflow. when th e bit 5 (data for control of event counter window) of the timer x mode regist er is set to ?1?, counting is stopped at the next timer 1 underflow. when the bit is set to ?0?, counting is restarted at the next timer 1 underflow. (6) pulse width measurement mode in this mode, the count source is the output of frequency divider for timer. in this mode, timer x operates as the 18-bit counter by setting the timer x register (extension). when the bit 6 of the cntr 0 active edge switch bits is ?0?, counting is executed during the ?h? interval of cntr 0 pin input. when the bit is ?1?, counting is executed during the ?l? interval of cntr 0 pin input. when using this mode, set the port sharing the cntr 0 pin to input mode. also, set to enable (?0?) the data for control of event counter window (bit 5 of timer x mode register (address 002d 16 )).
rev.3.02 apr 10, 2008 page 36 of 131 rej03b0177-0302 38d2 group fig. 27 waveform of pwm/igbt (1) write order to timer x ? in the timer mode, pulse output mode, event counter mode and pulse width measurement mode, write to the following registers in the order as shown below; the timer x regist er (extension), the timer x register (low-order), the timer x regist er (high-order). do not write to only one of them. when the above mode is set a nd timer x operates as the 16-bit counter, if the timer x register (extension) is never set after reset is released, setting the time r x register (extension) is not required. in this case, write th e timer x register (low-order) first and the timer x register (high-order). however, once writing to the timer x register (extension) is executed, note that the value is retained to the reload latch. ? write to the timer x register by the 16-bit unit. do not read the timer x register while write oper ation is performed. if the write operation is not completed, normal operation will not be performed. ? in the igbt output and pwm m odes, do not write ?1? to the timer x register (extension). al so, when ?1? is already written to the timer x register, be sure to write ?0? to the register before using. write to the following registers in the order as shown below; the compare registers 1, 2, 3 (high- and low-order), the timer x regist er (extension), the timer x register (low-order), the timer x regist er (high-order). it is possible to use whicheve r order to write to the compare registers 1, 2, 3 (high- and low-order). however, write both the compare registers 1, 2, 3 and the timer x register at the same time. for the compare registers, set a value less than the setting value in the timer x register . also, do not set ?00 16 ?. (2) read order to timer x ? in all modes, read the following registers in the order as shown below; the timer x regist er (extension), the timer x regist er (high-order), the timer x register (low-order). when reading the timer x register (extension) is not required, read the timer x register (high-order) first and the timer x register (low-order). read order to the compare regist ers 1, 2, 3 is not specified. ? read from the timer x re gister by the 16-bit unit. do not write to the timer x register while re ad operation is performed. if the read operation is not completed, normal operation will not be performed. (3) write to timer x ? which write control can be selected by the timer x write control bit (b3) of the time r x mode register (address 2d 16 ), writing data to both the latch and the timer at the same time or writing data only to the latch. when writing a value to the timer x address to write to the la tch only, the value is set into the reload latch and the timer is updated at the next underflow. after reset release, when wr iting a value to the timer x address, the value is set into the timer and the timer latch at the same time, because they are written at the same time. when writing to the latch only, if the write timing to the high- order reload latch and the und erflow timing are almost the same, the value is set into the timer and the timer latch at the same time. in this time, counti ng is stopped du ring writing to the high-order reload latch. ? switch the frequency division or count source* while the timer count is stopped. *this also applies when the frequency divider output is selected as the timer count source and th e count source is switched in conjunction with a transition between operating modes (on- chip oscillator mode, x in mode, or low-speed mode). be careful when changing settings in the cpu mode register. t s timer x count source timer x pwm mode igbt output mode m ts (n+1) ts the following pwm waveform is output; duty of t xout1 output :{(n+1)-m}/(n+1), duty of t xout2 output :(p-q)/(n+1), period :(n+1) ts t xout1 output (txcon1 bit 5 = ?0?) t xout2 output (txcon2 bit 1 = ?0?) q ts p ts n : timer x setting value m: compare register 1 setting value p : compare register 2 setting value q : compare register 3 setting value ts: one period of timer x count source external trigger (int 0 source) is generated. int 1 or int 2 source is generated. level is forcibly ?l? only igbt output mode. level is ?h? only igbt output mode.
rev.3.02 apr 10, 2008 page 37 of 131 rej03b0177-0302 38d2 group (4) set of timer x mode register set the write control bit of the timer x mode register to ?1? (write to the latch only) when setting the igbt output and pwm modes. output waveform simu ltaneously reflects the contents of both registers at the next underflow after writing to the timer x register (high-order). (5) output control function of timer x ? when using the output control function (int 1 and int 2 ) in the igbt output mode, set the levels of int 1 and int 2 to ?h? in the falling edge active or to ?l? in the rising edge active before switching to the igbt output mode. (6) switch of cntr 0 active edge ? when the cntr 0 active edge switch bits are set, at the same time, the interrupt active edge is also affected. when the pulse width is measur ed, set the bit 7 of the cntr 0 active edge switch bits to ?0?. (7) when timer x pulse width measurement mode used when timer x pulse width measurement mode is used, enable the event counter wind control data (bit 5 of timer x mode register (address 002d 16 )) by setting to ?0?. if the event counter window control data (bit 5 of timer x mode register (address 002d 16 )) is set to ?1? (disabled) to enable/disable the cntr 0 input, the input is not accepted after the timer 1 underflow. fig. 28 structure of timer x related registers timer x mode register (txm: address 002d 16 ) timer x operating mode bits b2b1b0 0 0 0 : timer mode 0 0 1 : pulse output mode 0 1 0 : igbt output mode 0 1 1 : pwm mode 1 0 0 : event counter mode 1 0 1 : pulse width measurement mode 1 1 0 : not available 1 1 1 : not available timer x write control bit 0 : write data to both timer latch and timer 1 : write data to timer latch only timer x count source selection bit 0 : frequency divider output 1 : f(x cin ) data for control of event counter window 0 : event count enabled 1 : event count disabled timer x count stop bit 0 : count operation 1 : count stop timer x output 1 selection bit (p3 5 ) 0 : i/o port 1 : timer x output 1 b7 b0 b0 timer x control register 1 (txcon1: address 002e 16 ) noise filter sampling clock selection bit 0 : f(x in )/2 1 : f(x in )/4 external trigger delay time selection bits b2b1 0 0 : not delayed 0 1 : (4/f(x in )) s 1 0 : (8/f(x in )) s 1 1 : (16/f(x in )) s timer x output control bit 1 (p5 1 ) 0 : not used int 1 interrupt signal 1 : int 1 interrupt signal used timer x output control bit 2 (p3 4 ) 0 : not used int 2 interrupt signal 1 : int 2 interrupt signal used timer x output 1 active edge switch bit 0 : start at ?l? output 1 : start at ?h? output cntr 0 active edge switch bits b7b6 0 0 : count at rising edge in event counter mode falling edge active for cntr 0 interrupt measure ?h? pulse width in pulse width measurement mode 0 1 : count at falling edge in event counter mode rising edge active for cntr 0 interrupt measure ?l? pulse width in pulse width measurement mode 1 0 : count at both edges in event counter mode 1 1 : both edges active for cntr 0 interrupt b7 timer x control register 2 (txcon2: address 002f 16 ) timer x output 2 control bit (p3 7 ) 0 : i/o port 1 : timer x output 2 timer x output 2 active edge switch bit 0 : start at ?l? output 1 : start at ?h? output timer x dividing frequency selection bits b3b2 0 0 : 1/16 source 0 1 : 1/1 source 1 0 : 1/2 source 1 1 : 1/256 source trigger for igbt input control bit 0 : noise filter sampling clock 1 external trigger delay time 1 1 : noise filter sampling clock 2 external trigger delay time 1/2 not used (returns ?0? when read) b7 b0 (1) note1: source indicates the followings: ?x in input in the frequency/2, 4, or 8 mode ?on-chip oscillator divided by 4 in the on-chip oscillator mode ?sub-clock in the low-speed mode
rev.3.02 apr 10, 2008 page 38 of 131 rej03b0177-0302 38d2 group fig. 29 block diagram of timer y ? timer y timer y is a 16-bit timer. th e timer y count source can be selected by setting the timer y mode register. x cin can be selected as the count source. when x cin is selected as the count source, counting can be performed regardless of x in oscillation or on-chip oscill ator oscillation. four operating modes can be selected for timer y by the timer y mode register. also, the real time port can be controlled. (1) timer mode the timer y count source can be selected by setting the timer y mode register. (2) period measurement mode the interrupt request is genera ted at rising or falling edge of cntr 1 pin input signal. simultane ously, the value in timer y latch is reloaded in timer y and timer y continues counting. except for that, this mode operates just as in the timer mode. the timer value just before the reloading at rising or falling of cntr 1 pin input is retained until th e timer y is read once after the reload. the rising or fall ing timing of cntr 1 pin input is found by cntr 1 interrupt. when using this mode, set the port sharing the cntr 1 pin to input mode. (3) event counter mode the timer counts signals input through the cntr 1 pin. except for that, this mode operates just as in the timer mode. when using this mode, set the port sharing the cntr 1 pin to input mode. (4) pulse width hl continuously measurement mode the interrupt request is generate d at both rising and falling edges of cntr 1 pin input signal. except fo r that, this mode operates just as in the period measuremen t mode. when using this mode, set the port sharing the cntr 1 pin to input mode. (5) real time port control when the real time port function is valid, data for the real time port is output from ports p4 6 and p4 7 each time the timer y underflows. (however, if the real time port control bits are changed from ?00 2 ? to ?11 2 ? after both data for real tim e ports are set, data are output independent of the timer y operation.) when either or both data for real time ports are changed while the real time port function is valid, the changed data is output at the next underflow of timer y. when switching the setting of the real time port control bits between valid and invalid, write to the timer y mode register in byte units with the ldm or sta in struction so that both bits are switched at the same time. also, before using this function, set the p4 6 and p4 7 port direction registers to output. data bus real time port control bits real time port control bits q d latch q d latch p4 7 direction register p4 7 latch p4 7 data for real time port p4 6 direction register p4 6 latch p4 6 data for real time port ?1? timer y (low-order) latch (8) timer y (high-order) latch (8) ?0? cntr 1 active edge switch bit ?10? p4 7 /rtp 1 /an 7 p4 6 /rtp 0 /an 6 cntr 1 falling edge detection period measurement mode timer y interrupt request pulse width hl continuous measurement mode timer y operating mode bits cntr 1 interrupt request rising edge detection count source selection bit xc in ?1? source real time port control bits timer y mode register write signal timer y operating mode bits ?00?, ?01?, ?11? ?11? ?00? ?11? ?00? ?11? ?00? ?00?, ?01?, ?10? ?11? ?0? timer y write control bit timer y count stop bit ?00? ?11? timer y mode register write signal real time port control bits timer y (low-order)(8) timer y (high-order)(8) frequency divider timer y dividing frequency selection bit 2 note: in frequency/2, frequency/4, or frequency/8 mode, source is the x in input. in on-chip oscillator mode, source is the on-chip oscillator frequency divided by 4. in low-speed mode, source is the sub-clock frequency.
rev.3.02 apr 10, 2008 page 39 of 131 rej03b0177-0302 38d2 group ? cntr 1 interrupt active edge selection cntr 1 interrupt active edge depends on the cntr 1 active edge switch bit. however, in pulse width hl continuously measurement mode, cntr 1 interrupt request is generated at both rising and fall ing edges of cntr 1 pin input signal regardless of the setting of cntr 1 active edge switch bit. ? timer y read/write control ? when reading from/writing to timer y, read from/write to both the high-order and low-order bytes of timer y. when the value is read, read the high-order by tes first and the low-order bytes next. when the value is written, write the low-order bytes first and the highorder bytes next. write to or read from the timer x register in 16-bit units. if reading from the timer y regist er during write operation or writing to it during read operation is performed, normal operation will not be performed. ? which write control can be selected by the timer y write control bit (b0) of the time r y control register (address 0039 16 ), writing data to both the latch and the timer at the same time or writing data only to the latch. when writing a value to the timer y address to write to the latch only, the value is set into the reload latch and the timer is updated at the next underflow. after reset release, when writing a value to the timer y address, the value is set into the timer and the timer latch at the same time, because they are set to write at the same time. when writing to the latch only, if the write timing to the high- order reload latch and the unde rflow timing are almost the same, the value is set into the timer and the timer latch at the same time. in this time, coun ting is stopped during writing to the high-order reload latch. ? this also applies when the frequ ency divider output is selected as the timer count source and th e count source is switched in conjunction with a transition between operating modes (on- chip oscillator mode, x in mode, or low-speed mode). be careful when changing settings in the cpu mode register. fig. 30 structure of timer y related registers b7 b0 timer y control register (tycon: address 0039 16 ) timer y write control bit 0 : write data to both timer latch and timer 1 : write data to timer latch only timer y count source selection bit 0 : frequency divider output 1 : f(x cin ) timer y frequency division selection bits b3 b2 0 0 : 1/16 source 0 1 : 1/1 source 1 0 : 1/2 source 1 1 : 1/256 source not used (returns ?0? when read) source: represents the supply source of internal clock . x in input: in the frequency/2, 4 or 8 mode, internal on-chip oscillator divided by 4 in the on-chip oscillator mode, and sub clock in the low-speed mode. real time port control bits (p4 6 , p4 7 ) b1 b0 0 0 : real time port function invalid 0 1 : do not set 1 0 : do not set 1 1 : real time port function valid p4 6 data for real time port p4 7 data for real time port timer y operating mode bits b5 b4 0 0 : timer mode 0 1 : period measurement mode 1 0 : event counter mode 1 1 : pulse width hl continuous measurement mode cntr 1 active edge switch bit 0 : count at rising edge in event counter mode measure falling period in period measurement mode falling edge active for cntr 1 interrupt 1 : count at falling edge in event counter mode measure rising period in period measurement mode rising edge active for cntr 1 interrupt timer y count stop bit 0 : count operation 1 : count stop timer y mode register (tym: address 0038 16 ) b0 b7
rev.3.02 apr 10, 2008 page 40 of 131 rej03b0177-0302 38d2 group serial interface ? serial i/o the 38d2 group has two 8-bit serial i/o (serial i/o1 and serial i/o2). serial i/o can be used as either clock synchronous or asynchronous (uart) serial i/ o. a dedicated timer is also provided for baud rate generation. (1) clock synchronous serial i/o mode clock synchronous serial i/o mode can be selected by setting the serial i/o mode selection bit of the serial i/o control register to ?1?. for clock synchronous serial i/o, the transmitter and the receiver must use the same clock. if an internal clock is used, transfer is started by a write signal to the tb/rb. fig. 31 block diagram of clock synchronous serial i/o fig. 32 operation of clock synchronous serial i/o function 1/4 1/4 f/f receive buffer register receive shift register receive buffer full flag (rbf) receive interrupt request (ri) clock control circuit shift clock serial i/o synchronous clock selection bit baud rate generator frequency division ratio 1/(n+1) brg count source selection bit clock control circuit falling-edge detector transmit buffer register data bus shift clock transmit shift completion flag (tsc) transmit buffer empty flag (tbe) transmit interrupt request (ti) transmit interrupt source selection bit data bus transmit shift register serial i/o control register serial i/o status register address 0018 16 [address 001d 16 ] address 0018 16 [address 001d 16 ] address 0019 16 [address 001e 16 ] address 001c 16 [address 0ff2 16 ] address 001a 16 [address 001f 16 ] p5 4 /r x d 1 [p3 3 /r x d 2 ] p5 6 /s clk1 [p3 1 /s clk2 ] p5 7 /s rdy1 [p3 0 /s rdy2 ] p5 5 /t x d 1 [p3 2 /t x d 2 ] [ ] : for serial i/o2 source: represents the supply source of internal clock . x in input: in the frequency/2, 4 or 8 mode, internal on-chip oscillator divided by 4 in the on-chip oscillator mode, and sub clock in the low-speed mode. source d 7 d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 0 d 1 d 2 d 3 d 4 d 5 d 6 rbf = 1 tsc = 1 tbe = 0 tbe = 1 tsc = 0 transfer shift clock (1/2 to 1/2048 of the internal clock, or an external clock) serial output txd serial input rxd write pulse to receive/transmit buffer register overrun error (oe) detection notes 1 : as the transmit interrupt (ti) source, which can be selected, either when the transmit buffer has emptied (tbe = 1) or after the transmit shift operation has ended (tsc = 1), by setting the transmit interrupt source selection bit (tic) of the serial i/o control register. 2 : if data is written to the transmit buffer register when tsc=0, the transmit clock is generated continuously and serial data is output continuously from the txd pin. 3 : the receive interrupt (ri) is set when the receive buffer full flag (rbf) becomes ?1? . receive enable signal s rdy d 7
rev.3.02 apr 10, 2008 page 41 of 131 rej03b0177-0302 38d2 group (2) asynchronous serial i/o (uart) mode clock asynchronous serial i/o mode (uart) can be selected by setting the serial i/o mode select ion bit of the serial i/o control register to ?0?. eight serial data transfer formats can be selected, and the transfer formats used by a transmitter and receiver must be identical. the transmit and receive shift re gisters each have a buffer, but the two buffers have the same address in memory. since the shift register cannot be written to or read from directly, transmit data is written to the transmit buffer register, and receive data is read from the receive buffer register. the transmit buffer register can also hold the next data to be transmitted, and the receive buffer register can hold a character while the next characte r is being received. fig. 33 block diagram of uart serial i/o fig. 34 operation of uart serial i/o function 1/4 oe pe fe 1/16 1/16 data bus receive buffer register receive shift register receive buffer full flag (rbf) receive interrupt request (ri) baud rate generator frequency division ratio 1/(n+1) transmit buffer register data bus transmit shift register transmit shift completion flag (tsc) transmit buffer empty flag (tbe) transmit interrupt request (ti) uart control register character length selection bit brg count sour ce selection bit transmit interrupt source selection bit serial i/o synchronous clock selection bit clock control circuit character length selection bit 7 bits 8 bits serial i/o status register serial i/o control register p5 4 /r x d 1 [p3 3 /r x d 2 ] p5 6 /s clk1 [p3 1 /s clk2 ] p5 5 /t x d 1 [p3 2 /t x d 2 ] address 0018 16 [address 001d 16 ] address 001c 16 [address 0fe2 16 ] address 0018 16 [address 001d 16 ] address 0019 16 [address 001e 16 ] address 001a 16 [address 001f 16 ] address 001b 16 [address 0fe1 16 ] [ ] : for serial i/o2 source: represents the supply source of internal clock . x in input: in the frequency/2, 4 or 8 mode, internal on-chip oscillator divided by 4 in the on-chip oscillator mode, and sub c lock in the low-speed mode. source sp detector st/sp/pa generator st detector tsc=0 tbe=1 rbf=0 tbe=0 tbe=0 rbf=1 rbf=1 st d 0 d 1 sp d 0 d 1 st sp tbe=1 tsc=1 ? st d 0 d 1 sp d 0 d 1 st sp serial input rxd ? generated at 2nd bit in 2-stop-bit mode 1 start bit 7 or 8 data bit 1 or 0 parity bit 1 or 2 stop bit (s) notes 1 : error flag detection occurs at the same time that the rbf flag becomes ?1? (at 1st stop bit, during reception). 2 : as the transmit interrupt (ti), when either the tbe or tsc flag becomes ?1?, can be selected to occur depending on the settin g of the transmit interrupt source selection bit (tic) of the serial i/o control register. 3 : the receive interrupt (ri) is set when the rbf flag becomes ?1?. 4 : after data is written to the transmit buffer when tsc flag = ?1?, 0.5 to 1.5 cycles of the data shift cycle is necessary unti l changing to tsc flag = ?0?. transmit or receive clock transmit buffer register write signal serial output txd receive buffer register read signal
rev.3.02 apr 10, 2008 page 42 of 131 rej03b0177-0302 38d2 group [transmit buffer register/receive buffer register (tb1, rb1/tb2, rb2)] the transmit buffer register and the receive buffer register are located at the same address. the transmit buffer is write-only and the receive buffer is read-only. if a character bit length is 7 bits, the msb of data stored in the receive buffer is ?0?. [serial i/o status register (sio1sts, sio2sts)] the read-only serial i/o status re gister consists of seven flags (bits 0 to 6) which indicate the operating status of the serial i/o function and various errors. three of the flags (bits 4 to 6) are valid only in uart mode. the receive buffer full flag (bit 1) is set to ?0? when the receive buffer register is read. if there is an error, it is detect ed at the same time that data is transferred from the receive shift register to the receive buffer register, and the receive buffer full flag is set. a write to the serial i/o status regi ster sets all the error flags oe, pe, fe, and se (bit 3 to bit 6, respectively) to ?0?. writing ?0? to the serial i/o enable bit sioe (bit 7 of the serial i/o control register) also sets all the status flags to ?0?, including the error flags. all bits of the serial i/o status register are set to ?0? at reset, but if the transmit enable bit (bit 4) of the serial i/o control register has been set to ?1?, the transmit shift completion flag (bit 2) and the transmit buffer empty flag (bit 0) become ?1?. [serial i/o control register (sio1con, sio2con)] the serial i/o control register c onsists of eight control bits for the serial i/o function. [uart control register (uart1con, uart2con)] the uart control register consists of four control bits (bits 0 to 3) which are valid when asynchro nous serial i/o is selected and set the data format of the data transfer and one bit (bit 4) which is always valid and sets the output structure of the p5 5 /t x d 1 [p3 2 /txd 2 ] pin. [baud rate genera tor (brg1, brg2)] the baud rate generator determin es the baud rate for serial transfer. the baud rate generator divides the frequency of the count source by 1/(n + 1), where n is the value written to the baud rate generator. when setting transmit enable bit of serial i/o to ?1?, the serial i/o transmit interrupt request b it is automatically set to ?1?. when not requiring the interrupt occurrence synchronous with the transmission enabled, take the following sequence. (1) set the serial i/o transmit interrupt enable bit to ?0? (disabled). (2) set the transmit enable bit to ?1?. (3) set the serial i/o transmit interrupt request bit to ?0? after 1 or more instructions have been executed. (4) set the serial i/o transmit interrupt enable bit to ?1? (enabled).
rev.3.02 apr 10, 2008 page 43 of 131 rej03b0177-0302 38d2 group fig. 35 structure of serial i/o related registers b7 b0 b7 b0 b7 b0 brg count source selection bit (css) 0: source 1: source/4 serial i/o synchronous clock selection bit (scs) 0: brg output divided by 4 when clock synchronous serial i/o is selected. brg output divided by 16 when uart is selected. 1: external clock input when clock synchronous serial i/o is selected. external clock input divided by 16 when uart is selected. s rdy output enable bit (srdy) 0: p5 7 [p3 0 ] pin operates as ordinary i/o pin 1: p5 7 [p3 0 ] pin operates as s rdy output pin transmit interrupt source selection bit (tic) 0: interrupt when transmit buffer has emptied 1: interrupt when transmit shift operation is completed transmit enable bit (te) 0: transmit disabled 1: transmit enabled receive enable bit (re) 0: receive disabled 1: receive enabled serial i/o mode selection bit (siom) 0: clock asynchronous (uart) serial i/o 1: clock synchronous serial i/o serial i/o enable bit (sioe) 0: serial i/o disabled (pins p5 4 [p3 0 ] to p5 7 [p3 3 ] operate as ordinary i/o pins) 1: serial i/o enabled (pins p5 4 [p3 0 ] to p5 7 [p3 3 ] operate as serial i/o pins) transmit buffer empty flag (tbe) 0: buffer full 1: buffer empty receive buffer full flag (rbf) 0: buffer empty 1: buffer full transmit shift completion flag (tsc) 0: transmit shift in progress 1: transmit shift completed overrun error flag (oe) 0: no error 1: overrun error parity error flag (pe) 0: no error 1: parity error framing error flag (fe) 0: no error 1: framing error summing error flag (se) 0: (oe) u (pe) u (fe)=0 1: (oe) u (pe) u (fe)=1 not used (returns ?1? when read) serial i/o control register (sio1con : address 001a 16 ) [sio2con : address 001f 16 ] serial i/o status register (sio1sts : address 0019 16 ) [sio2sts : address 001e 16 ] character length selection bit (chas) 0: 8 bits 1: 7 bits parity enable bit (pare) 0: parity checking disabled 1: parity checking enabled parity selection bit (pars) 0: even parity 1: odd parity stop bit length selection bit (stps) 0: 1 stop bit 1: 2 stop bits p5 5 /txd 1 [p3 2 /txd 2 ] p-channel output disable bit (poff) 0: cmos output (in output mode) 1: n-channel open drain output (in output mode) not used (return ?1? when read) uart control register (uart1con : address 001b 16 ) [uart2con : address 0ff1 16 ] ( ) : for serial i/o1 [ ] : for serial i/o2 source: represents the supply source of internal clock . x in input: in the frequency/2, 4 or 8 mode, internal on-chip oscillator divided by 4 in the on-chip oscillator mode, and sub clock in the low-speed mode.
rev.3.02 apr 10, 2008 page 44 of 131 rej03b0177-0302 38d2 group a/d converter the 38d2 group has a 10-bit a/d converter. the a/d converter performs successive approximatio n conversion. the 38d2 group has the adkey function which pe rform a/d conversion of the ?l? level analog input from the adkey pin automatically. [ad conversion register (adl, adh)] one of these registers is a high-o rder register, and the other is a low-order register. the high-order 8 bits of a conversion result is stored in the ad conversion register (high-order) (address 0017 16 ), and the low-order 2 bits of the same result are stored in bit 7 and bit 6 of the ad conversi on register (low-order) (address 0016 16 ). during a/d conversion, do not read these registers. also, the connection between the resistor ladder and reference voltage input pin (v ref ) can be controlled by the v ref input switch bit (bit 0 of address 0016 16 ). when ?1? is written to this bit, the resistor ladder is always connected to v ref . when ?0? is written to this bit, the resistor ladder is disconnected from v ref except during the a/d conversion. [ad control register (adcon)] this register controls a/d convert er. bits 2 to 0 are analog input pin selection bits. bit 3 is an ad conversion completion bit and ?0? during a/d conversion. this bit is set to ?1? upon completion of a/d conversion. a/d conversion is started by setting ?0? in this bit. bit 5 is the adkey enable bit. the adkey function is enabled by setting ?1? to this bit. when this function is valid, the analog input pin selection bits are ignore d. also, when bit 5 is ?1?, do not set ?0? to bit 3 by program. [comparison voltage generator] the comparison voltage generato r divides the voltage between av ss and v ref , and outputs the divided voltages. [channel selector] the channel selector select s one of the input ports p4 7 /an 7 ? p4 0 /an 0 and inputs it to the comparator. [comparator and control circuit] the comparator and control ci rcuit compare an analog input voltage with the comparison voltage and store the result in the ad conversion register. when an a/d conversion is completed, the control circuit sets the ad conversion completion bit and the ad conversion interrupt request bit to ?1?. the comparator is constructe d linked to a capacitor. the conversion accuracy may be low beca use the change is lost if the conversion speed is not enough. accordingly, set f(x in ) to at least 500 khz during a/d conversion in the x in mode. also, do not execute the stp an d wit instructions during the a/d conversion. in the low-speed mode and on-ch ip oscillator mode, there is no limit on the oscillation frequency because the on-chip oscillator is used as the a/d conversion cl ock. in the low-speed mode, on- chip oscillator starts oscillation automatically at the a/d conversion is executed and stops oscillation automatically at the a/d conversion is finished even though it is not oscillating. fig. 36 block diagram of a/d converter (address 0017 16 ) (address 0016 16 ) adkey control circuit a/d control circuit av ss b7 b0 data bus channel selector ad conversion register (h) resistor ladder comparator a/d interrupt request ad control register p4 0 /an 0 p4 1 /an 1 p4 2 /an 2 /adkey p4 3 /an 3 p4 4 /an 4 p4 5 /an 5 p4 6 /an 6 p4 7 /an 7 ad conversion register (l) v ref 1/8 1/2 source note: in frequency/2, frequency/4, or frequency/8 mode, source is the x in input. in low-speed mode, or on-chip oscillator mode, source is the on-chip oscillator frequency divided by 4.
rev.3.02 apr 10, 2008 page 45 of 131 rej03b0177-0302 38d2 group fig. 37 structure of ad control register adkey function the adkey function is used to judge the analog input voltage input from the adkey pin. when the a/d converter starts operating after v il (0.7 vcc-0.5) or less is input, the event of analog voltage input can be ju dged with the a/d conversion interrupt. this function can be used with the stp and wit state. as for the adkey function in 38d2 group, the a/d conversion of analog input voltage immediately after starting adkey function is not performed. therefore, the a/d conversion result immedi ately after an adkey function is un defined. accordingl y, when the a/d conversion result of the analog input voltage input from the adkey pin is required, start the a/d conversion by program after the analog input pin corres ponding to adkey is selected. ? adkey selection when the adkey pin is used, set the adkey selection bit to ?1?. the adkey selection bit is ?0?, just after the a/d conversion is started. ? adkey enable the adkey function is enabled by writing ?1? to the adkey enable bit. surely, in order to enable adkey function, set ?1? to the adkey enable bit, after setting the adkey selection bit to ?1?. when the adkey enable bit of th e ad control register is ?1?, the analog input pin selection bits become invalid. please do not write ?0? in the ad conversion completion bit by the program during adkey en abled state. [adkey control circuit] in order to obtain a more exact conversion result, by the a/d conversion with adkey, execute the following; ? set the input to the adkey pin into a steep falling waveform, ? stabilize the input voltage within 8 clock cycles (1 s at f(x in ) = 8 mhz) after the input voltage is under v il the threshold vo ltage with an actual adkey pin is the voltage between v ih -v il . in order not to make adkey ope ration perform superfluously in a noise etc., in the state of the waiting for an input, set the voltage of an adkey pin to v ih (0.9v cc ) or more. when the following operatio ns are performed, the a/d conversion operation ca nnot be guaranteed. ? when the cpu mode register is operated during a/d conversion operation, ? when the ad conversion control register is operated during a/d conversi on operation, ? when the stp or wit instruction is executed during a/d conversion operation. ad control register (adcon: address 0015 16 ) analog input pin selection bits b2 b1 b0 0 0 0 : p4 0 /an 0 0 0 1 : p4 1 /an 1 0 1 0 : p4 2 /an 2 0 1 1 : p4 3 /an 3 1 0 0 : p4 4 /an 4 1 0 1 : p4 5 /an 5 1 1 0 : p4 6 /an 6 1 1 1 : p4 7 /an 7 ad conversion completion bit 0 : conversion in progress 1 : conversion completed ad conversion clock selection bit 0 : source/2 1 : source/8 adkey enable bit 0 : disabled 1 : enabled 10-bit or 8-bit conversion switch bit 0 : 10-bit ad 1 : 8-bit ad adkey selection bit 0 : invalid 1 : valid b7 b0 *v ref input switch bit 0: on only during a/d conversion 1: on note : the bit 5 to bit 1 of address 0016 16 become ?0? at reading. also, bit 0 is undefined at reading. (low-order) * b1 b0 b7 b0 ad conversion register high-order (address 0017 16 ) b7 b2 b3 b6 b5 b4 b9 b8 (high-order) b7 b0 at 10bitad (read address 0017 16 before 0016 16 ) b5 b0 b1 b4 b3 b2 b7 b6 b7 b0 notes 1 : source indicates the followings: ?x in input in the frequency/2, 4, or 8 mode ?on-chip oscillator divided by 4 in the low-speed and the on-chip oscillator mode 2 : when the adkey enable bit is ?1?, the analog input pin selection bits are invalid. do not execute the a/d conversion by program while the adkey is enabled. bit 0 to bit 2 of adcon are not changed even when adkey is enabled. ad conversion register low-order (address 0016 16 ) at 8bitad (read only address 0017 16 ) (address 0017 16 ) ( 2 ) (1)
rev.3.02 apr 10, 2008 page 46 of 131 rej03b0177-0302 38d2 group lcd drive control circuit the 38d2 group has the built-in liquid crystal display (lcd) drive control circuit c onsisting of the following. ? lcd display ram ? segment output disable register ? lcd mode register ? selector ? timing controller ? common driver ? segment driver ? bias control circuit a maximum of 24 segment output pins and 4 common output pins can be used. up to 96 pixels can be controlled for an lcd display. when the lcd enable bit is set to ?1? af ter data is set in the lcd mode register, the segment output disabl e register, and the lcd display ram, the lcd drive control circ uit starts reading the display data automatically, performs the bias control and the duty ratio control, and displays th e data on the lcd panel. . fig. 38 structure of lcd related registers table 11 maximum number of disp lay pixels at each duty ratio duty ratio maximum number of display pixels 2 48 dots or 8 segment lcd 6 digits 3 72 dots or 8 segment lcd 9 digits 4 96 dots or 8 segment lcd 12 digits lcd mode register (lm : address 0013 16 ) b7 b0 duty ratio selection bits b1b0 0 0 : not used 0 1 : 2 (use com 0 , com 1 ) 1 0 : 3 (use com 0 -com 2 ) 1 1 : 4 (use com 0 -com 3 ) bias control bit 0 : 1/3 bias 1 : 1/2 bias lcd enable bit 0 : lcd off 1 : lcd on lcd drive timing selection bit 0 : type a 1 : type b lcd circuit divider division ratio selection bits b6b5 0 0 : clock input 0 1 : 2 division of clock input 1 0 : 4 division of clock input 1 1 : 8 division of clock input lcdck count source selection bit ( note 3 ) 0 : f(x cin )/32 1 : source /8192 segment output disable register 0 (seg0 : address 0ff4 16 ) b7 b0 segment output disable bit 0 0 : segment output seg 0 1 : output port p0 0 segment output disable bit 1 0 : segment output seg 1 1 : output port p0 1 segment output disable bit 2 0 : segment output seg 2 1 : output port p0 2 segment output disable bit 3 0 : segment output seg 3 1 : output port p0 3 segment output disable bit 4 0 : segment output seg 4 1 : output port p0 4 segment output disable bit 5 0 : segment output seg 5 1 : output port p0 5 segment output disable bit 6 0 : segment output seg 6 1 : output port p0 6 segment output disable bit 7 0 : segment output seg 7 1 : output port p0 7 segment output disable register 1 (seg1 : address 0ff5 16 ) b7 b0 segment output disable bit 8 0 : segment output seg 8 1 : output port p1 0 segment output disable bit 9 0 : segment output seg 9 1 : output port p1 1 segment output disable bit 10 0 : segment output seg 10 1 : output port p1 2 segment output disable bit 11 0 : segment output seg 11 1 : output port p1 3 segment output disable bit 12 0 : segment output seg 12 1 : output port p1 4 segment output disable bit 13 0 : segment output seg 13 1 : output port p1 5 segment output disable bit 14 0 : segment output seg 14 1 : output port p1 6 segment output disable bit 15 0 : segment output seg 15 1 : output port p1 7 segment output disable register 2 (seg2 : address 0fe6 16 ) b7 b0 segment output disable bit 16 0 : segment output seg 16 1 : output port p2 0 segment output disable bit 17 0 : segment output seg 17 1 : output port p2 1 segment output disable bit 18 0 : segment output seg 18 1 : output port p2 2 segment output disable bit 19 0 : segment output seg 19 1 : output port p2 3 segment output disable bit 20 0 : segment output seg 20 1 : output port p2 4 segment output disable bit 21 0 : segment output seg 21 1 : output port p2 5 segment output disable bit 22 0 : segment output seg 22 1 : output port p2 6 segment output disable bit 23 0 : segment output seg 23 1 : output port p2 7 notes 1 : only pins set to output ports by the dire ction register can be controlled to switch to output ports or segment outputs by the segment output disable register. 2 : when the v l pin input selection bit (vlsel) of the lcd power control register (address 0038 16 ) is ?1?, settings of the segment output disable bit 22 and segment output disable bit 23 are invalid. 3 : lcdck is a clock for an lcd timing controller. source represents the supply source of internal clock . x in input: in the frequency/2, 4 or 8 mode, internal on-chip oscill ator divided by 4 in the on-chip oscillator mode, and sub clock in the low-speed mode. (1) (1) (1)
rev.3.02 apr 10, 2008 page 47 of 131 rej03b0177-0302 38d2 group fig. 39 block diagram of lcd controller/driver data bus timing controller lcd divider f(x cin )/32 source/8192 level shift level shift level shift level shift bias control selector selector selector selector selector selector level shift level shift level shift level shift level shift level shift segment driver segment driver segment driver com 0 com 1 com 2 com 3 v ss p2 7 /seg 23 /v l2 v l3 p2 6 /seg 22 /v l1 p0 3 /seg 3 p0 2 /seg 2 p0 1 /seg 1 p0 0 /seg 0 address 0040 16 address 0041 16 p2 0 /seg 16 ?0? ?1? lcdck lcdck count source selection bit lcd circuit divider division ratio selection bits bias control bit lcd enable bit duty ratio selection bits 2 2 lcd display ram segment driver segment driver segment driver lcd power control register 5 p2 7 / v l2 seg 23 / p2 6 / v l1 seg 22 / address 004c 16 notes 1 : source represents the supply source of internal clock . x in input: in the frequency/2, 4 or 8 mode, internal on-chip oscillator divided by 4 in the on-chip oscillator mode, and sub clock in the low-speed mode. common driver common driver common driver common driver
rev.3.02 apr 10, 2008 page 48 of 131 rej03b0177-0302 38d2 group ? bias control and applied voltage to lcd power input pins when the voltage is applied from the lcd power input pins (v l1 ? v l3 ), set the v l pin input selection bit (bit 5 of the lcd power control register) and v l3 connection bit (bit 6 of lcd power control register) to ?1?, apply the voltage value shown in table 12 according to the bias value. in this case, seg 22 pin and seg 23 pin cannot be used. select a bias value by the bias control bit (bit 2 of the lcd mode register). note: v lcd is the maximum value of supplied voltage for the lcd panel. ? common pin and duty ratio control the common pins (com 0 ? com 3 ) to be used are determined by duty ratio. select duty ratio by the duty ratio selection bits (bits 0 and 1 of the lcd mode register). when reset is released, v cc voltage is output from the common pin. note: unused common pin outputs the unselected waveform. ? segment signal output pin the segment signal output pins (seg 0 ? seg 23 ) are shared with ports p0 ? p2. when these pins are used as the segment signal output pins, set the direction regi sters of the corresponding pins to ?1?, and set the segment output disable register to ?0?. also, these pins are set to the input port after reset, the v cc voltage is output by the pull-up resistor. fig. 40 example of circuit at each bias (at external power input) table 12 bias control and applied voltage to v l1 ? v l3 bias value voltage value 1/3 bias v l3 = v lcd v l2 = 2/3 v lcd v l1 = 1/3 v lcd 1/2 bias v l3 = v lcd v l2 = v l1 = 1/2 v lcd table 13 duty ratio control and common pins used duty ratio duty ratio selection bits common pins used bit 1 bit 0 20 1com 0 , com 1 31 0com 0 ? com 2 41 1com 0 ? com 3 r4 r5 r4 = r5 contrast adjust 1/2 bias contrast adjust r1 r2 r3 r1 = r2 = r3 1/3 bias v l1 v l3 v l2 v l1 v l3 v l2
rev.3.02 apr 10, 2008 page 49 of 131 rej03b0177-0302 38d2 group ? lcd power circuit the lcd power circuit has the dividing resistor for lcd power which can be connected/disconnected with the lcd power control register. to use the lcd, apply a voltage externally to the v l3 pin and set the v l3 connect bit to ?1?. an exte rnal voltage should be applied even if a voltage equivalent to v cc is used for the v l3 pin. when the lcd is not used, perform either of the following. ? set the v l3 connect bit to ?0? and leave the v l3 pin open. ?set the v l3 connect bit to ?1? and apply a v cc level to v l3 pin. fig. 41 structure of lcd power control register fig. 42 v l block diagram dividing resistor for lcd power control bit (lcdron) 0 : internal dividing resistor disconnected from lcd power circuit 1 : internal dividing resistor connected to lcd power circuit lcd power control register (vlcon : address 0014 16 ) b7 b0 v l pin input selection bit (vlsel) ( note 2 ) 0 : input invalid 1 : v l input function valid not used (do not write to ?1?.) dividing resistor for lcd power selection bits (rsel) ( note 1 ) b2b1 1 0 : 0 1 : 0 0 : 1 1 : v l3 connection bit 0 : connect lcd internal v l3 to v cc 1 : connect lcd internal v l3 to v l3 pin notes 1 : when voltage is applied to v l1 to v l3 by using the external resistor, write ?10 2 ? to dividing resistor for lcd power selection bits. 2 : setting to the v l pin input selection bit (vlsel) = ?1? has the most priority than setting to the port p2 direction register (address 0005 16 ) and segment output disable register 2 (address 0ff6 16 ). larger resistor smaller resistor not used (do not write to ?1?.) v l3 p2 7 /seg 23 /v l2 bias control bit (lcd mode register) p2 6 /seg 22 /v l1 v l pin input selection bit dividing resistor for lcd power control bit vcc dividing resistor for lcd power dividing resistor for lcd power selection bits v l3 connection bit lcd internal v l3 lcd internal v l2 lcd internal v l1
rev.3.02 apr 10, 2008 page 50 of 131 rej03b0177-0302 38d2 group ? lcd display ram the 12-byte area of address 0040 16 to 004b 16 is the designated ram for the lcd display. when ?1? is written to these addresses, the corresponding segmen ts of the lcd display panel are turned on. ? lcd drive timing for the lcd drive timing, type a or type b can be selected. the lcd drive timing is selected by the timing selection bit (bit 4 of lcd mode register). type a is selected by setting the lcd drive timing selection bit to ?0?, type b is selected by setting the bit to ?1?. type a is selected after reset. the lcdck timing frequency (lcd drive timing) is generated internally and the frame frequency can be determined with the following equation; f(lcdck) = frame frequency = (1) when the stp instruction is ex ecuted, the following bits are set to ?0?; ? lcd enable bit (bit 3 of lcd mode register) ? bits other than bit 6 of the lcd power control register. and the lcd panel turns off. to make the lcd panel turn on after returning from the stop mode, set these bits to ?1?. (2) when the voltage is applied to v l1 to v l3 by using the external resistor, write ?10 2 ? to dividing resistor for lcd power selection bits (rsel) of the lcd power control register (address 0038 16 ). (3) when the lcd drive contro l circuit is used at v l3 = v cc , apply v cc to v l3 pin and write ?1? to v l3 connection bit of the lcd power control register (address 0038 16 ). fig. 43 lcd display ram map (frequency of count source for lcdck) (divider division ratio for lcd) f(lcdck) duty ratio bit address 0040 16 0041 16 0042 16 0043 16 0044 16 0045 16 0046 16 0047 16 0048 16 0049 16 004a 16 004b 16 seg 1 seg 3 seg 5 seg 7 seg 9 seg 11 seg 13 seg 15 seg 17 seg 19 seg 21 seg 23 seg 0 seg 2 seg 4 seg 6 seg 8 seg 10 seg 12 seg 14 seg 16 seg 18 seg 20 seg 22 7 6 54 32 10 com 3 com 2 com 1 com 0 com 3 com 2 com 1 com 0
rev.3.02 apr 10, 2008 page 51 of 131 rej03b0177-0302 38d2 group fig. 44 lcd drive waveform (1/2 bias, type a) internal signal lcdck timing 1/4 duty voltage level v l3 v l2 =v l1 v ss v l3 v ss com 0 com 1 com 2 com 3 seg 0 off on off on com 3 com 2 com 1 com 0 com 3 com 2 com 1 com 0 1/3 duty v l3 v l2 =v l1 v ss v l3 v ss off on on off on off 1/2 duty com 0 com 1 com 2 seg 0 com 0 com 1 seg 0 v l3 v l2 =v l1 v ss v l3 v ss off on off on off on off on com 0 com 2 com 1 com 0 com 2 com 1 com 0 com 2 com 1 com 0 com 1 com 0 com 1 com 0 com 1 com 0 lcd lcd lcd
rev.3.02 apr 10, 2008 page 52 of 131 rej03b0177-0302 38d2 group fig. 45 lcd drive waveform (1/3 bias, type a) internal signal lcdck timing 1/4 duty voltage level v l3 v ss com 0 com 1 com 2 com 3 seg 0 off on off on com 3 com 2 com 1 com 0 com 3 com 2 com 1 com 0 1/3 duty off on on off on off 1/2 duty com 0 com 1 com 2 seg 0 com 0 com 1 seg 0 off on off on off on off on v l3 v l2 v ss v l1 v l3 v l2 v ss v l1 v l3 v ss v l3 v l2 v ss v l1 v l3 v ss com 0 com 2 com 1 com 0 com 2 com 1 com 0 com 2 com 1 com 0 com 1 com 0 com 1 com 0 com 1 com 0 lcd lcd lcd
rev.3.02 apr 10, 2008 page 53 of 131 rej03b0177-0302 38d2 group fig. 46 lcd drive waveform (1/2 bias, type b) internal signal lcdck timing 1/4 duty voltage level com 0 com 1 com 2 com 3 seg 0 off on off on com 3 com 2 com 1 com 0 com 3 com 2 com 1 com 0 1/3 duty off on on off on off 1/2 duty com 0 com 1 com 2 seg 0 com 0 com 1 seg 0 off on off on off on off on v l3 v l2= v l1 v ss com 0 com 2 com 1 com 0 com 2 com 1 com 0 com 2 com 1 com 0 com 1 com 0 com 1 com 0 com 1 com 0 1 frame 1 frame 1 frame 1 frame 1 frame 1 frame 1 frame 1 frame v l3 v ss v l3 v ss v l3 v ss v l3 v l2= v l1 v ss v l3 v l2= v l1 v ss lcd lcd lcd
rev.3.02 apr 10, 2008 page 54 of 131 rej03b0177-0302 38d2 group fig. 47 lcd drive waveform (1/3 bias, type b) internal signal lcdck timing 1/4 duty voltage level com 0 com 1 com 2 com 3 seg 0 off on off on com 3 com 2 com 1 com 0 com 3 com 2 com 1 com 0 1/3 duty off on on off on off 1/2 duty com 0 com 1 com 2 seg 0 com 0 com 1 seg 0 off on off on off on off on v l3 v l2 v ss v l1 v l3 v l2 v ss v l1 v l3 v l2 v ss v l1 com 0 com 2 com 1 com 0 com 2 com 1 com 0 com 2 com 1 com 0 com 1 com 0 com 1 com 0 com 1 com 0 1 frame 1 frame 1 frame 1 frame 1 frame 1 frame 1 frame 1 frame v l3 v l2 v ss v l1 v l3 v l2 v ss v l1 v l3 v l2 v ss v l1 lcd lcd lcd
rev.3.02 apr 10, 2008 page 55 of 131 rej03b0177-0302 38d2 group rom correction function a part of program in rom can be corrected. set the start address of the corr ected rom data (i.e. an op code address of the beginning instru ction) to the rom correction address high-order and low-order registers. when the program is being ex ecuted and the value of the program counter matches with th e set address value in the rom correction address registers, the program is branched to the rom correction vectors and then the correction program can be executed by setting it to th e rom correction vectors. use the jmp instruction (3-byte in struction) to return the main program from the correction program. the correctable area is up to two. there are two vectors for rom correction. also, rom correction vector can be selected from the ram area or rom area by the rom corre ction memory selection bit. the rom correction function is controlled by the rom correction address 1 enable bit and rom correction address 2 enable bit. if the rom correction function is not used, the rom correction vector may be used as norma l ram/rom. when using the rom correction vector as normal ram/rom, make sure to set bits 1 and 0 in the rom correction enable register to ?0? (disable). 1. when using the rom correction function, set the rom cor- rection address registers and then enable the rom correc- tion with the rom correction enable register. 2. do not set addresses other than the rom area in the rom correction address registers. do not set the same rom corre ction addresses in both the rom correction address registers 1 and rom correction address registers 2. 3. it is necessary to contain the process for rom correction in the program. fig. 48 rom correction address register fig. 49 memory map of M38D24g4 fig. 50 structure of rom correction enable register ram area rc2 = ?0? rom area rc2 = ?1? vector 1 address 0100 16 address f100 16 vector 2 address 0120 16 address f120 16 0ff8 16 rom correction address 1 high-order register (rca1h) rom correction address 1 low-order register (rca1l) rom correction address 2 high-order register (rca2h) rom correction address 2 low-order register (rca2l) 0ff9 16 0ffa 16 0ffb 16 note: do not set address other than rom area. c080 16 sfr area interrupt vector area reserved rom area 0100 16 0000 16 0040 16 0120 16 ff00 16 ffff 16 zero page special page 02bf 16 efff 16 ram rom protect area 1 f120 16 ffdb 16 reserved rom area c000 16 f100 16 rom correction vector 1 rom correction vector 2 rom correction vector 1 rom correction vector 2 ~ ~ ~ ~ rom correction address 1 enable bit (rc0) 0 : disable 1 : enable rom correction address 2 enable bit (rc1) 0 : disable 1 : enable rom correction memory selection bit (rc2) 0 : branch to the ram area 1 : branch to the rom area not used (returns ?0? when read) rom correction enable register (address 0ffc 16 ) rcr b7 b0 note: after rom correction address register is set, set the rom correction address enable bit to be enabled.
rev.3.02 apr 10, 2008 page 56 of 131 rej03b0177-0302 38d2 group watchdog timer the watchdog timer gives a mean of returning to the reset status when a program cannot run on a normal loop (for example, because of a software run-away ). the watchdog timer consists of an 8-bit counter. ? initial value of watchdog timer at reset or writing to the watc hdog timer control register, each watchdog timer is set to ?ff 16 ?. instructions such as sta, ldm and clb to generate the wr ite signals can be used. the written data in bits 7, 6 or 5 are not valid, and the above values are set. bits 7 to 5 can be rewritten only once after re leasing reset. after rewriting it is disable to write any data to this bit. this bit becomes ?0? after reset. ? standard operation of watchdog timer the watchdog timer is in the st op state at rese t and the watchdog timer starts to count down by writing an optional value in the watchdog timer control register. an internal reset occurs at an underflow of the watchdog timer. then , reset is released after the reset release time is elapsed, the program starts from the reset vector address. normally, writing to the watchdog timer control register before an underflow of the watchdog timer is programmed. if writing to the watchdog timer contro l register is not executed, the watchdog timer does not operate. when reading the watchdog timer control register is executed, the contents of the high-order 5-bit counter, the count source selection bit 2 (bit 5), the stp instruction function selection bit (bit 6), and the count source sele ction bit (bit 7) are read out. ? bit 6 of watchdog timer control register 1. when bit 6 of the watchdog timer control register is ?0?, the mcu enters the stop mode by ex ecution of stp instruction. just after releasing the stop mode, the watchdog timer restarts counting (note 1) . when executing the wit instruction, the watc hdog timer does not stop. 2. when bit 6 is ?1?, executi on of stp instruction causes an internal reset. when this bit is set to ?1? once, it cannot be rewritten to ?0? by program. bit 6 is ?0? at reset. 3. the time until the underflow of the watchdog timer register after writing to the watchdog time r control register is exe- cuted is as follows (when the bit 7 of the watchdog timer control register is ?0?); 4. at x in mode (f(x in )) = 8 mhz): 32.768 ms 5. at low-speed mode (f(x cin ) = 32 khz): 8.19s 1. the watchdog timer continues to count even during the wait time set by timer 1 and timer 2 to release the stop state and in the wait mode. accordingly, write to the watchdog timer control register to not underflow the watchdog timer in this time. 2. when the on-chip oscillator is selected by the watchdog timer count source selection bi t 2, the on-chip oscillator forcibly oscillates and it cannot be stopped. also, in this time, set the stp instruction f unction selection bit to ?1? at this time. select ?0? ( source) the watchdog timer count source selection bit 2 at the system which on-chip oscillator is stopped. fig. 51 block diagram of watchdog timer fig. 52 structure of watchdog timer control register 1/1024 watchdog timer h (5) watchdog timer count source selection bit reset circuit ?ff 16 ? is set when watchdog timer control register is written to. internal reset wait until reset release watchdog timer l (3) 1/4 ?0? ?1? source ?0? ?1? on-chip oscillator 1/4 watchdog timer count sourse selection bit 2 data bus note1: source indicates the followings: ?x in input in the frequency/2, 4, or 8 mode ?on-chip oscillator divided by 4 in the on-chip oscillator mode ?sub-clock in the low-speed mode (1) stp instruction function selection bit undefined instruction reset stp instruction reset watchdog timer h (for read-out of high-order 5 bit) ?ff 16 ? is set to watchdog timer by writing to these bits. watchdog timer count source selection bit 2 0 : source 1 : on-chip oscillator/4 watchdog timer control register (wdtcon : address 0029 16 ) b7 b0 watchdog timer count source selection bit 0 : count source/1024 1 : count source/4 stp instruction function selection bit 0 : entering stop mode by execution of stp instruction 1 : internal reset by execution of stp instruction notes 1 : source indicates the followings: ?x in input in the frequency/2, 4 , or 8 mode ?on-chip oscillator divided by 4 in the on-chip oscillator mode ?sub-clock in the low-speed mode 2 : when the on-chip oscillator is selected by the watchdog timer count source selection bit 2, set the stp instruction function selection bit to ?1?. select (source) as the count source at the system which on-chip oscillator is stopped. 3 : bits 7 to 5 can be rewritten only once after reset. after rewriting it is disable to write any data to this bit. (1)
rev.3.02 apr 10, 2008 page 57 of 131 rej03b0177-0302 38d2 group clock output function a system clock can be output from i/o port p3 6 . the triple function of i/o port, timer 2 outp ut function and system clock output function is performed by th e clock output control register (address 0ff3 16 ) and the timer 2 output selection bit of the timer 12 mode register (address 0025 16 ). in order to output a system clock from i/o port p3 6 , set the timer 2 output selection bit and b it 0 of the clock output control register to ?1?. when the clock output function is selected, a clock is output while the direction register of port p3 6 is set to the output mode. p3 6 is switched to the port outpu t or the output (timer 2 output and the clock output) except port at the cycle after the timer 2 output control bit is switched. fig. 53 structure of clock output control register fig. 54 block diagram of clock output function other function registers [rrf register (rrfr)] the rrf register (address 0012 16 ) is the 8-bit register and does not have the control function. as for the value written in this register, high-order 4 bits and low-order 4 bits interchange. it is initialized after reset. fig. 55 structure of rrf register b7 b0 clock output control register (ckout : address 0ff3 16 ) p3 6 clock output control bit 0 : timer 2 output 1 : system clock output not used (returns ?0? when read) not used (do not write ?1? to these bits.) timer 2 latch (8) timer 2 (8) 1/2 q q s t t 2out output edge switch bit p3 6 clock output control bit ?0? ?1? p3 6 latch timer 2 output selection bit p3 6 direction register p3 6 /t 2out / ckout b7 b0 timer 12 mode register (address 0025 16 ) t12m timer 2 output selection bit 0 : i/o port 1 : timer 2 output system clock timer 2 output control bit ?0? ?1? b7 b0 rrf register db 4 data storage db 5 data storage db 6 data storage db 7 data storage db 0 data storage db 1 data storage db 2 data storage db 3 data storage (rrfr : address 0012 16 )
rev.3.02 apr 10, 2008 page 58 of 131 rej03b0177-0302 38d2 group reset circuit to reset the microcomputer, reset pin should be held at an ?l? level for 2 s or more. then the reset pin is returned to an ?h? level (the power source vol tage should be between v cc (min.) and 5.5 v), rese t is released. after the reset is completed, the program starts from the address contained in address fffd 16 (high-order byte) and address fffc 16 (low-order byte). make sure that the reset input voltage meets v il spec. when a power source voltage passes v cc (min.). in the flash memory version, input to the reset pin in the following procedure. ? when power source is stabilized (1) input ?l? level for 2 s or more to reset pin. (2) input ?h? level to reset pin. ? at power-on (1) input ?l? level to reset pin. (2) increase the power source voltage to 2.7 v. (3) wait for td(p-r) until intern al power source has stabilized. (4) input ?h? level to reset pin. in the qzrom version, the input level applied to the oscsel pin is determined when the reset pin changes from ?l? to ?h?. fig. 56 reset circuit example fig. 57 reset sequence v cc power source voltage detection circuit reset v cc reset 0 v 0 v v cc reset 0.2v cc or less 0 v 0 v v cc reset td(p-r) or more 5 v 5 v 2.7 v (1) note 1 : qzrom version: 2 s or more flash memory version: td(p-r) or more v cc (min.) reset internal reset address data sync system clock oscsel=l: oco oscsel=h: x in fffc fffd ad h, ad l ad l ad h ???? reset address from vector table oscsel=l: oco= about 32768 cycles oscsel=h: x in = about 8192 cycles notes 1 : the frequency of system clock is f(oco)/32 or f(x in )/8. 2 : the question marks (?) indicate an undefined state. 3 : in the qzrom version, the input level applied to the oscsel pin is determined when the reset pin changes from ?l? to ?h?.
rev.3.02 apr 10, 2008 page 59 of 131 rej03b0177-0302 38d2 group fig. 58 internal status at reset 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 0010 16 0011 16 0012 16 0013 16 0014 16 0015 16 0019 16 001a 16 001b 16 001e 16 001f 16 0020 16 0021 16 0022 16 0023 16 0024 16 0025 16 0026 16 0027 16 0028 16 0029 16 address 002a 16 002b 16 002c 16 002d 16 002e 16 002f 16 0030 16 0031 16 0032 16 0033 16 0034 16 0035 16 0036 16 0037 16 0038 16 0039 16 003a 16 003b 16 003c 16 003d 16 003e 16 003f 16 0ff0 16 0ff1 16 0ff3 16 0ff4 16 0ff5 16 0ff6 16 0ff7 16 0ff8 16 0ff9 16 0ffa 16 0ffb 16 0ffc 16 (ps) (pc h ) (pc l ) port p0 port p0 direction register port p1 port p1 direction register port p2 port p2 direction register port p3 port p3 direction register port p4 port p4 direction register port p5 port p5 direction register port p6 port p6 direction register oscillation output control register cpu mode register 2 rrf register lcd mode register lcd power control register ad control register serial i/o1 status register serial i/o1 control register uart1 control register serial i/o2 status register serial i/o2 control register timer 1 timer 2 timer 3 timer 4 pwm01 register timer 12 mode register timer 34 mode register timer 1234 mode register timer 1234 frequency division selection register watchdog timer control register (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20) (21) (22) (23) (24) (25) (26) (27) (28) (29) (30) (31) (32) (33) (34) (35) timer x (low-order) timer x (high-order) timer x (extension) timer x mode register timer x control register 1 timer x control register 2 compare register 1 (low-order) compare register 1 (high-order) compare register 2 (low-order) compare register 2 (high-order) compare register 3 (low-order) compare register 3 (high-order) timer y (low-order) timer y (high-order) timer y mode register timer y control register interrupt edge selection register cpu mode register interrupt request register 1 interrupt request register 2 interrupt control register 1 interrupt control register 2 pull register uart2 control register clock output control register segment output disable register 0 segment output disable register 1 segment output disable register 2 key input control register rom correction address 1 high-order register (rca1h) rom correction address 1 low-order register (rca1l) rom correction address 2 high-order register (rca2h) rom correction address 2 low-order register (rc2al) rom correction enable register processor status register program counter (36) (37) (38) (39) (40) (41) (42) (43) (44) (45) (46) (47) (48) (49) (50) (51) (52) (53) (54) (55) (56) (57) (58) (59) (60) (61) (62) (63) (64) (65) (66) (67) (68) (69) (70) (71) 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 register contents 00 16 00 16 00 16 08 16 00 16 00 16 ff 16 01 16 ff 16 ff 16 00 16 00 16 00 16 00 16 00 16 address 00000 0* 0 00011 11 1 10000 00 0 11100 00 0 ff 16 ff 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 ff 16 ff 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 00 16 ff 16 ff 16 ff 16 00 16 00 16 00 16 00 16 00 16 00 16 register contents *1*00 00 0 1 fffd 16 contents fffc 16 contents 10000 00 0 11100 00 0 : not fixed *: depends on oscsel setting at the qzrom version. in the flash memory version, the cpu mode register 2 (address 0011 16 ), is set to ?00 16 ? and the cpu mode register (address 003b 16 ) is set to ?e0 16 ?. since the initial values for other than above mentioned registers and ram contents are indefinite at reset, they must be set.
rev.3.02 apr 10, 2008 page 60 of 131 rej03b0177-0302 38d2 group clock generating circuit the oscillation circuit of 38d2 group can be formed by connecting an oscillator, capac itor and resistor between x in and x out (x cin and x cout ). to supply a clock signal externally, input it to the x in pin and make the x out pin open. the clocks that are externally generated cannot be directly input to x cin . use the circuit constants in accordance with the oscillator manufacturer's recommended values. no external resistor is needed between x in and x out since a feed-back resistor exists on-chip. (an external feed-b ack resistor may be needed depending on conditions.) however, an about 10 m external feedback resistor is needed between x cin and x cout . the 38d2 group operation m ode immediately after reset depends on the oscsel pin st ate in the qzrom version. when the oscsel pin state is gnd level, the only on-chip oscillator starts oscillating. the x in -x out oscillation stops oscillating, and x cin and x cout pins function as i/o ports. flash memory version as same. when the oscsel pin state is v cc level, the x in -x out oscillation divided by 8 starts oscillating. the on-chip oscillator stops oscillating, and the x cin and x cout pins function as i/o ports. note the following in each mode. ?x in mode the x in -x out oscillation does not stop even if the x in -x out oscillation stop bit is set to ?1?. ? low-speed mode the x cin -x cout oscillation stops if the port x c switch bit is set to ?0?. ? on-chip oscillator mode even if the on-chip oscillator stop bit is set to ?1?, the on-chip oscillator oscillation does not st op in the flash memory version, but stops in the qzrom version. ? frequency control (1) on-chip oscillation mode the system clock is the on-chip oscillator oscillation divided by 32. (2) x in mode frequency/2 mode, frequency /4 mode, and frequency/8 mode are collectively referred as x in mode. - frequency/8 mode the system clock is the frequency of x in divided by 8. - frequency/4 mode the system clock is the frequency of x in divided by 4. - frequency/2 mode the system clock is half the frequency of x in . (3)low-speed mode the system clock is half the frequency of sub clock. after reset and when system returns from the stop mode, the operation mode depends on the oscsel pin state in the qzrom version and the flash me mory version operation mode is the on-chip oscillator mode. when the reset pin changes from ?l? to ?h? and when the stp instruction is executed, determine the input level applied to the oscsel pin. refer to the clock state transition diagram for the setting of transition to each mode. the x in - out oscillation is controlled by the bit 5 of cpum, and the sub-clock oscillation is controlled by the bit 4 of cpum and the on-chip oscillator oscillation is controlled by the bit 0 of cpum2. in the on-chip oscillator mode, the oscillation by the oscillator can be stopped. in the low-sp eed mode, the power consumption can be reduced by stopping the x in ? x out oscillation. in low-speed mode, the on-chip oscillator stops in the qzrom version regardless of the on-chip oscillator stop bit value. the on-chip oscillator does not stop in the flash memory version, so set the on-chip oscillator stop bi t to ?1? to stop the oscillation. set enough time for oscillation to stabilize by programming to restart the stopped oscillation and switch the operation mode. also, set enough time for oscillation to stabilize by programming to switch the timer count source. if you switch the mode between on-chip oscillator mode, x in mode and low-speed mode, stabilize both x in and x cin oscillations. especially be careful immediately after power-on and at returning from stop mode. refer to the clock state transition diagram for the setting of transition to each mode. set the frequency in the condition that f(x in ) > 3 ? f(x cin ). when the x in mode is not used (x in -x out oscillation and external clock input are not performed), connect x in to v cc through a resistor.
rev.3.02 apr 10, 2008 page 61 of 131 rej03b0177-0302 38d2 group ? oscillation control (1) stop mode if the stp instruction is executed, the system clock stops at an ?h? level, and main clock a nd sub-clock oscillators stop. in this time, values set previously to timer 1 latch and timer 2 latch are loaded automatically to timer 1 and timer 2. set the values * to generate the wait time required for oscillation stabilization to timer 1 latch and timer 2 latch (l ow-order 8 bits of timer 1 and high-order 8 bits of timer 2) before the stp instruction. the frequency divider for timer 1 is used for the timer 1 count source, and the output of timer 1 is forcibly connected to timer 2. in this time, bits 0 to 5 of the timer 12 mode register are cleared to ?0?. the values of the timer 1234 frequ ency divider selection register are not changed. set the interrupt enable bits of the timer 1 and timer 2 to be disabled (?0?) before exec uting the stp instruction. *: reference (set values according to your oscillator and system.) oscsel = ?l? of the qzrom version and flash memory version: .............. ........... ............ ........... ........... ......... ...... 0005 16 or more oscsel = ?h? of the qzrom version: ..........................................................................01ff 16 or more when an external interrupt is received, the clock set according to the oscsel pin state starts oscillating in the qzrom version. the operation mode at returning is decided by the clock that set according to the oscsel pin state. bits 3, 5, 6, and 7 of cpum and bit 0 of cpum2 are forcibly changed by the oscsel pin state. in the flash memory version, the on-chip oscillator starts oscillating an d the operation mode at returning is set to on-chip oscill ator mode. the bit 3 of cpum is changed to ?0?, bits 5, 6 and 7 of cpum are changed to ?1?, and the bit 0 of cpum2 is changed to ?0? forcibly. oscillator restarts when reset oc curs or an interrupt request is received, but the system clock is not supplied to the cpu until timer 2 underflows. this allows time for the clock circuit oscillation to stabilize. (2) wait mode if the wit instruction is executed, only the system clock stops at an ?h? state. the states of ma in clock, on-chip oscillator and sub clock are the same as the state before executing the wit instruction, and oscill ation does not stop. since supply of system clock is started immediately after th e interrupt is received, the instruction can be executed immediately. fig. 59 ceramic resonator circuit example fig. 60 external clock input circuit x cin x cout x in x out c in c out c cin c cout rf rd note : insert a damping resistor if required. the resistance will vary depending on the oscillator and the oscillation drive capacity setting. use the value recommended by the maker of the oscillator. also, if the oscillator manufacturer's data sheet specifies that a feedback resistor be added external to the chip though a feedback resistor exists on-chip, insert a feedback resistor between x in and x out following the instruction. rd x cin x cout x in x out external oscillation circuit open v cc v ss c cin rf rd c cout
rev.3.02 apr 10, 2008 page 62 of 131 rej03b0177-0302 38d2 group fig. 61 clock generating circuit block diagram system clock interrupt request interrupt disable flag i reset wit instruction s r q stp instruction x in -x out oscillation stop bit cpum bit5 x in x out x cout x cin timer 1 count source selection bits port xc switch bit cpum bit4 ?00? ?01? ?10? ?11? main clock division ratio selection bit cpum bit7, 6 on-chip oscillator internal system clock selection bit cpum bit3 1/2 1/2 internal system clock selection bit ?0? ?1? stp instruction s r q s r q ?1? ?0? timer 1 timer 2 ?01? ?00? frequency divider for timer timer 2 count source selection bits ?00? ?10? (2) 1/4 1/2 ?0? ?1? ?1? ?0? ?0? cpum2 bit0 on-chip oscillator stop bit main clock division ratio selection bit notes 1 : when the x cin -x cout oscillation is selected as the system clock, set the port xc switch bit to ?1?. 2 : although a feed-back resistor exists on-chip, an external feed-back resistor may be needed depending on conditions. 3 : source indicates the followings: ?x in input in the frequency/2, 4, or 8 mode ?on-chip oscillator divided by 4 in the on-chip oscillator mode ?sub-clock in the low-speed mode however, when used as the a/d conversion clock by the a/d converter, source indicates the followings: ?x in input in the frequency/2, 4, or 8 mode ?on-chip oscillator divided by 4 in the low-speed or the on-chip oscillator mode source cpum bit6 (1) (3)
rev.3.02 apr 10, 2008 page 63 of 131 rej03b0177-0302 38d2 group fig. 62 state transitions of system clock frequency/2 mode cm 4 x in oscillation (frequency/2) x cin oscillation oco oscillation or stop =f(x in )/ 2 cm 7 =0 cm 6 =0 cm 5 =0 cm 4 =1 cm 3 =0 cm 8 =* frequency/8 mode cm4 cm4 cm4 cm5 cm5 cm 5 x in stop x cin oscillation oco stop =f(x cin )/ 2 cm 7 =1 (invalid) cm 6 =1 (invalid) cm 5 =1 cm 4 =1 cm 3 =1 cm 8 =1 cm5 (cm7) cm3, cm8 (6) on-chip oscillator mode low-speed mode (6) cm7 (6) cm7 x in oscillation x cin oscillation oco stop =f(x cin )/ 2 cm 7 =0 (invalid) cm 6 =1 (invalid) cm 5 =0 cm 4 =1 cm 3 =1 cm 8 =1 x in stop x cin oscillation oco oscillation =f(oco)/32 cm 7 =1 cm 6 =1 cm 5 =1 cm 4 =1 cm 3 =0 cm 8 =0 x in oscillation x cin oscillation oco oscillation =f(oco)/32 cm 7 =1 cm 6 =1 cm 5 =0 cm 4 =1 cm 3 =0 cm 8 =0 x in oscillation x cin stop oco oscillation =f(oco)/32 cm 7 =1 cm 6 =1 cm 5 =0 cm 4 =0 cm 3 =0 cm 8 =0 x in stop x cin stop oco oscillation =f(oco)/32 cm 7 =1 cm 6 =1 cm 5 =1 cm 4 =0 cm 3 =0 cm 8 =0 cm3, cm7, cm8 (6) cm 4 x in oscillation (frequency/8) x cin oscillation oco oscillation or stop =f(x in )/ 8 cm 7 =0 cm 6 =1 cm 5 =0 cm 4 =1 cm 3 =0 cm 8 =* x in oscillation (frequency/8) x cin stop oco oscillation or stop =f(x in )/ 8 cm 7 =0 cm 6 =1 cm 5 =0 cm 4 =0 cm 3 =0 cm 8 =* cm6 cm6 reset release frequency/4 mode cm4 x in oscillation (frequency/4) x cin oscillation oco oscillation or stop =f(x in )/ 4 cm 7 =1 cm 6 =0 cm 5 =0 cm 4 =1 cm 3 =0 cm 8 =* x in oscillation x cin oscillation oco stop =f(x cin )/ 2 cm 7 =0 (invalid) cm 6 =0 (invalid) cm 5 =0 cm 4 =1 cm 3 =1 cm 8 =1 x in oscillation x cin oscillation oco stop =f(x cin )/ 2 cm 7 =1 (invalid) cm 6 =0 (invalid) cm 5 =0 cm 4 =1 cm 3 =1 cm 8 =1 cm6 x in oscillation (frequency/2) x cin stop oco oscillation or stop =f(x in )/ 2 cm 7 =0 cm 6 =0 cm 5 =0 cm 4 =0 cm 3 =0 cm 8 =* x in oscillation (frequency/4) x cin stop oco oscillation or stop =f(x in )/ 4 cm 7 =1 cm 6 =0 cm 5 =0 cm 4 =0 cm 3 =0 cm 8 =* * : the oco oscillating at 0; the oco stopped at 1. cm6 cm7 cm3 cm6 cm7 cm3 cm6 (cm7) cm6 cm5 (cm7) cm6 cm5 cm3 notes 1 :switchthemodebythearrowsshownbetweenthemodeblocks. theallmodescanbeswitchedtothestopmodeorthewaitmode. 2 : timer and lcd operate in the wait mode. system is returned to the source mode when the wait mode is ended. 3 : the cm4 value is retained in the stop mode. when the stop mode is ended, the operation mode varies as follows: in the qzrom version: mode set by the oscsel pin state in the flash memory version: on-chip oscillator mode the input level applied to the oscsel pin is determined when executing the stp instruction. 4 : before executing the stp instruction, set the values to genera te the wait time required for oscillation stabilization to timer 1 and timer 2, and set to "0" (interrupts disabled) to the interrupt enable bits o f timer 1 and timer 2. 5 : execute the transition after the oscillation used in the destination mod e is stabilized. 6 : when system goes to on-chip oscillator mode, the oscillation stabilizin g wait time is not needed. 7 : the on-chip oscillator can be stopped in all kinds of state of frequency/ 2,4 mode. 8 :in all x in mode, stop of on-chip oscillator is enabled. 9 : the example assumes that 8 mhz is being applied to the x in pin and 32 khz to the x cin pin. f(oco) indicates the oscillation frequency of on- chip oscillator. 10 : when selecting the on-chip oscillator for the wdt clock, the on-chip oscillator does not stop. also, in low-speed mode, the on-chip oscillator stops in the qzr om version regardless of the on-chip oscillator stop bit value. t he on-chip oscillator does not stop in the flash memory version, so set th is bit to "1" to stop the oscillation. in on-chip oscillator mode, even if this bit is set to "1", the on-chip oscillator oscillation does not stop in the flash memory versio n, but stops in the qzrom version. 11 : in low-speed mode, the x cin -x cout oscillation stops if the port x c switch bit is set to "0". 12 :in x in mode, the x in -x out oscillation does not stop even if the x in - x out oscillation stop bit is set to "1". 13 : 12.5 mhz < f(x in ) 16 mhz is not available in the frequency/2 mode. 14 : in the flash memory version, set the on-chip oscillator stop b it to "1" (oscillation stops) because oco is in the state set by the sett ing value of the on-chip oscillator stop bit. on-chip oscillator stop bit 0:oscillating 1 : stopped not used (do not write 1) not used (returns 0 when read) not used (do not write 1) processor mode bits b1 b0 0 0 : single-chip mode 01: 10: 11: stack page selection bit 0:0page 1:1page internal system clock selection bit 0 : main clock selected (includes oco, x in ) 1:x cin ? x cout selected port xc switch bit 0 : i/o port function (oscillation stop) 1:x cin ? x cout oscillating function x in ? x out oscillation stop bit 0 : oscillating 1 : stopped main clock division ratio selection bit (valid only when cm3=0) b7 b8 00:f(x in )/2 (frequency/2 mode) 01:f(x in )/8 (frequency/8 mode) 10:f(x in )/4 (frequency/4 mode) 1 1 : on-chip oscillator b7 b0 cpu mode register 2 cpum2 (address 0011 16 , qzrom version, oscsel=l, initial value: 00 16 ) ( qzrom version, oscsel=h, initial value: 01 16 ) ( flash memory version, initial value: 00 16 ) cm8 b7 b0 cpu mode register cpum (address 003b 16 , qzrom version, oscsel=l, initial value: e0 16 ) ( qzrom version, oscsel=h, initial value: 40 16 ) ( flash memory version, initial value: e0 16 ) cm0 cm1 cm2 cm3 cm4 cm5 cm6 cm7 not available (13) ? qzrom version ? flash memory version oscsel=l ? qzrom version oscsel=h (14) (12) (11)
rev.3.02 apr 10, 2008 page 64 of 131 rej03b0177-0302 38d2 group ? oscillation external output function the 38d2 group has the oscillati on external output function to output the rectangular waveform of the clock obtained by the oscillation circuits from p4 1 and p4 0 . in order to validate the oscillat ion external output function, set p4 0 or p4 1 , or both to the output mode (set the corresponding direction register to ?1?). the level of the x cout external output signal becomes ?h? by the p4 0 /p4 1 oscillation output control b its (bits 0 and 1) of the oscillation output contro l register (address 0010 16 ) in the following states; ? the function to output the signal from the x cout pin externally is selected ? the sub clock (x cin ? x cout ) is in the stop oscillating or stop mode. likewise, the level of the x out external output signal becomes ?h? by the p4 0 /p4 1 oscillation output cont rol bits (bits 0 and 1) of the oscillation output c ontrol register (address 0010 16 ) in the following states; ? the function to output the signal from the x out pin externally is selected ? the main clock (x in ? x out ) is in the stop oscillating or stop mode. when the signal from the x out pin or x cout pin of the oscillation circuit is i nput directly to the circuit except this mcu and used, the system opera tion may be unstabilized. in order to share the oscillation circuit safely, use the clock output from p4 0 and p4 1 by this function for the circuits except this mcu. fig. 63 structure of oscilla tion output control register fig. 64 block diagram of oscillation external output function b7 oscillation output control register (oscout : address 0010 16 ) p4 0 /p4 1 oscillation output control bits b 1 b 0 0 0 : p4 1 , p4 0 = normal port 0 1 : p4 1 = normal port, p4 0 = x out 1 0 : p4 1 = normal port, p4 0 = x cout 1 1 : p4 1 = x cout , p4 0 = x out not used (do not write to ?1?.) b0 stp instruction s r q x in x out interrupt request interrupt disable flag i reset x in -x out oscillation stop bit (cpum bit 5) p6 1 /x cin p6 2 /x cout port xc switch bit (cpum bit 4) p4 1 /o out1 p4 0 /o out0 p4 1 direction register p4 0 direction register oscout control p4 1 output latch p4 0 output latch oscillation output selection circuit
rev.3.02 apr 10, 2008 page 65 of 131 rej03b0177-0302 38d2 group qzrom writing mode in the qzrom writing mode , the user rom area can be rewritten while the microcomputer is mounted on-board by using a serial programmer which is app licable for this microcomputer. table 14 lists the pin descript ion (qzrom writing mode) and figure 65 shows th e pin connection. refer to figure 66 to figure 69 for examples of a connection with a serial programmer. contact the manufacturer of y our serial programmer for serial programmer. refer to the user?s manual of your serial programmer for details on how to use it. table 14 pin description (qzrom writing mode) pin name i/o function v cc , v ss power source input ? apply 2.7 to 5.5 v to v cc , and 0 v to v ss . reset reset input input ? reset input pin for active ?l?. reset occurs when reset pin is held at an ?l? level for 16 cycles or more of x in . x in clock input input ? set the same termination as the single-chip mode. x out clock output output v ref analog reference voltage input ? input the reference volt age of a/d converter to v ref . av ss analog power source input ? connect avss to vss. p0 0 ? p0 7 p1 0 ? p1 7 p2 0 ? p2 7 p3 3 ? p3 7 p4 0 ? p4 7 p5 0 ? p5 7 p6 0 ? p6 2 i/o port i/o ? input ?h? or ?l? level signal or leave the pin open. oscsel v pp input input ? qzrom programmable power source pin. p3 2 esda input/output i/o ? serial data i/o pin. p3 1 esclk input input ? serial clock input pin. p3 0 espgmb input input ? read/pr ogram pulse input pin.
rev.3.02 apr 10, 2008 page 66 of 131 rej03b0177-0302 38d2 group fig. 65 pin connection diagram package type : plqp0064ga-a(64p6 u-a)/plqp0064kb-a(64p6q-a) p0 6 /seg 6 p0 7 /seg 7 p1 0 /seg 8 p1 1 /seg 9 p1 2 /seg 10 p1 3 /seg 11 p1 4 /seg 12 p1 5 /seg 13 p1 6 /seg 14 p1 7 /seg 15 61 32 31 30 29 28 27 26 25 24 23 22 21 6 7 8 9 10 11 12 13 14 15 16 45 44 43 42 41 40 39 38 37 36 35 34 33 p2 4 /seg 20 p2 5 /seg 21 com 2 com 1 com 0 p2 7 /seg 23 /v l2 p2 6 /seg 22 /v l1 com 3 p0 3 /seg 3 /(kw 7 ) p 0 4 / s e g 4 p0 5 /seg 5 p5 1 /int 1 p5 6 /s clk1 /(kw 2 ) p5 5 /t x d 1 /(kw 1 ) p5 4 /r x d 1 /(kw 0 ) p5 3 /t 4out /pwm 1 p2 0 /seg 16 p2 1 /seg 17 p2 2 /seg 18 p2 3 /seg 19 49 50 51 52 53 48 47 46 62 63 64 12345 20 19 18 17 55 56 57 58 59 60 M38D2xgxfp/hp 54 p3 6 /t 2out /ckout/(led 6 ) p5 2 /t 3out /pwm 0 vref v l3 p4 7 /rtp 1 /an 7 p4 6 /rtp 0 /an 6 p3 2 /t x d 2 /(led 2 ) p3 1 /s clk2 /(led 1 ) p3 3 /r x d 2 /(led 3 ) p5 0 /int 0 av ss p0 2 /seg 2 /(kw 6 ) p0 1 /seg 1 /(kw 5 ) p0 0 /seg 0 /(kw 4 ) p5 7 /s rdy1 /(kw 3 ) p3 5 /t xout1 /(led 5 ) p3 4 /int 2 /(led 4 ) p3 0 /s rdy2 /(led 0 ) p6 0 /cntr 1 p3 7 /cntr 0 /t xout2 /(led 7 ) x out p4 3 /an 3 p4 2 /adkey/an 2 p4 4 /an 4 p4 5 /an 5 v ss p4 1 /o out1 /an 1 p4 0 /o out0 /an 0 oscsel p6 2 /x cout p6 1 /x cin v cc x in reset gnd v pp reset vcc espgmb esclk esda * : connect to oscillation circuit. : qzrom pin *
rev.3.02 apr 10, 2008 page 67 of 131 rej03b0177-0302 38d2 group fig. 66 when using e8 programmer, connection example (1) (oscsel = ?l?) 38d2 group reset circuit set the same termination as the single-chip mode. vcc p3 2 (esda) p3 1 (esclk) p3 0 (espgmb) reset vss avss x in x out * 1 : open-collector buffer note : for the programming circuit, the wiring capacity of each signal pin must not exceed 47 pf. vcc 14 12 10 8 13 9 7 4 2 6 3 1 * 1 oscsel 4.7 k 5 11 4.7 k qzrom version
rev.3.02 apr 10, 2008 page 68 of 131 rej03b0177-0302 38d2 group fig. 67 when using e8 programmer, connection example (2) (oscsel = ?h?) 38d2 group reset circuit set the same termination as the single-chip mode. v cc oscsel p3 2 (esda) p3 1 (esclk) p3 0 (espgmb) reset vss avss x in x out * 2 jumper switch 4.7 k * 1 : open-collector buffer * 2 : when programming 38d2 group is performed, disconnec t vcc from oscsel by a jumper switch. note : for the programming circuit, the wiring capacity of each signal pin must not exceed 47 pf. vcc 14 12 10 8 13 11 9 7 4 2 6 3 1 * 1 5 4.7 k qzrom version
rev.3.02 apr 10, 2008 page 69 of 131 rej03b0177-0302 38d2 group fig. 68 when using programmer of suisei electronics system co., ltd, connection example (1) (oscsel = ?l?) 38d2 group t_vdd t_vpp t_rxd t_sclk t_pgm/oe/md t_reset gnd reset circuit set the same termination as the single-chip mode. vcc oscsel p3 2 (esda) p3 1 (esclk) p3 0 (espgmb) reset vss avss x in x out 4.7k note: for the programming circuit, the wiring capacity of each signal pin must not exceed 47 pf. t_busy t_txd n.c. 4.7k qzrom version
rev.3.02 apr 10, 2008 page 70 of 131 rej03b0177-0302 38d2 group fig. 69 when using programmer of suisei electronics system co., ltd, connection example (2) (oscsel = ?h?) 38d2 group t_vdd t_vpp t_rxd t_sclk t_pgm/oe/md t_reset gnd reset circuit set the same termination as the single-chip mode. vcc oscsel p3 2 (esda) p3 1 (esclk) p3 0 (espgmb) reset vss avss x in x out * 1 jumper switch 4.7k * 1 : when programming qzrom is performed, disconnec t vcc from oscsel by a jumper switch. note: for the programming circuit, the wiring capacity of each signal pin must not exceed 47 pf. t_txd t_busy n.c. 4.7k qzrom version
rev.3.02 apr 10, 2008 page 71 of 131 rej03b0177-0302 38d2 group flash memory mode the 38d2 group flash memory version has the flash memory that can be rewritten with a single power source. for this flash memory, three flash memory modes are available in which to read, program, an d erase: the parallel i/o and standard serial i/o modes in which the flash memory can be manipulated using a programmer and the cpu rewrite mode in which the flash memory can be manipulated by the central processing unit (cpu). for details of each mode, refer to the next and after pages. cont act the manufacturer of your programmer for the programmer. refer to the user's manual of your programmer for details on how to use it. this flash memory version has some blocks on the flash memory as shown in figure 70 and each block can be erased. in addition to the ordinary us er rom area to store the mcu operation control program, the fl ash memory has a boot rom area that is used to store a pr ogram to control rewriting in cpu rewrite and standard serial i/o modes. this boot rom area has had a standard serial i/o mode c ontrol program stored in it when shipped from the factory. however, the user can write a rewrite control program in this area that suits the user?s application system. this boot rom area can be rewritten in only parallel i/o mode. performance overview table 15 lists the performance overview of the 38d2 group flash memory version. note: 1. the boot rom area has had a standard serial i/o mode cont rol program stored in it when shipped from the factory. this boot rom area can be erased and written in only parallel i/o mode. table 15 performance overview of 38d2 group flash memory version parameter function power source voltage (vcc) v cc = 2.7 to 5.5 v program/erase vpp voltage (v pp )v cc = 2.7 to 5.5 v flash memory mode 3 modes; parallel i/o mode, standard serial i/o mode, cpu rewrite mode erase block division user rom area/data rom area refer to figure 70. boot rom area (1) not divided (4k bytes) program method in units of bytes erase method block erase program/erase control method program/erase control by software command number of commands 5 commands number of program/erase times 100 rom code protection available in parallel i/o mode and standard serial i/o mode
rev.3.02 apr 10, 2008 page 72 of 131 rej03b0177-0302 38d2 group boot mode the control program for cpu rewrite mode must be written into the user rom or boot rom area in parallel i/o mode beforehand. (if the control program is written into the boot rom area, the standard serial i/o mode becomes unusable.) see figure 70 for details about the boot rom area. normal microcomputer mode is entered when the microcomputer is reset with pulling cnv ss pin low. in this case, the cpu starts operating using the control program in the user rom area. when the microcomputer is reset and the cnv ss pin high after pulling the p3 2 /txd 2 pin and cnv ss pin high, the cpu starts operating (start address of progr am is stored into addresses fffc 16 and fffd 16 ) using the control program in the boot rom area. this mode is called the ?boot mode?. also, user rom area can be rewritten using the control program in the boot rom area. block address block addresses refer to the maximum address of each block. these addresses are used in the block erase command. cpu rewrite mode in cpu rewrite mode, the internal flash memory can be operated on (read, program, or erase) under control of the central processing unit (cpu). in cpu rewrite mode, only the user rom area shown in figure 70 can be rewritten; the boot rom area cannot be rewritten. make sure the program and block erase commands are issued for only the user rom area and each block area. the control program for cpu rewrite mode can be stored in either user rom or boot rom area. in the cpu rewrite mode, because the flash memory cannot be read from the cpu, the rewrite control program must be transferred to internal ram area before it can be executed. fig 70. block diagram of built-in flash memory data block a: 1k bytes block 1: 26k bytes block 0: 32 k bytes ffff 16 8000 16 1800 16 1400 16 1000 16 user rom area data block b: 1k bytes sfr area internal ram area (2k bytes) ffff 16 1000 16 0fff 16 0fe0 16 083f 16 0040 16 0000 16 ffff 16 f000 16 boot rom area 4k bytes sfr area internal flash memory area (60k bytes) ram notes1 : the boot rom area can be rewritten in a parallel i/o mode. (access to except boot rom area is disabled.) 2 : to specify a block, use the maximum address in the block. 3 : the qzrom version has the reserved rom area. note the difference of the area.
rev.3.02 apr 10, 2008 page 73 of 131 rej03b0177-0302 38d2 group outline performance cpu rewrite mode is usable in th e single-chip or boot mode. the only user rom area can be rewritten. in cpu rewrite mode, the cpu erases, programs and reads the internal flash memory as instructed by software commands. this rewrite control program must be transferred to internal ram area before it can be executed. the mcu enters cpu rewrite m ode by setting ?1? to the cpu rewrite mode select bit (bit 1 of address 0fe0 16 ). then, software commands can be accepted. use software commands to control program and erase operations. whether a program or erase operation has terminated normally or in error can be verifi ed by reading the status register. figure 71 shows the flash me mory control register 0. bit 0 of the flash memory control register 0 is the ry/by status flag used exclusively to read the operating status of the flash memory. during programming and er ase operations, it is ?0? (busy). otherwise, it is ?1? (ready). bit 1 of the flash memory contro l register 0 is the cpu rewrite mode select bit. when this bit is set to ?1?, the mcu enters cpu rewrite mode. and then, software commands can be accepted. in cpu rewrite mode, the cpu b ecomes unable to access the internal flash memory directly . therefore, use the control program in the internal ram for write to bit 1. to set this bit 1 to ?1?, it is necessary to write ?0? and then write ?1? in succession to bit 1. the bit can be set to ?0? by only writing ?0?. bit 2 of the flash memory control register 0 is the user block 1 e/w enable bit. by setting combination of bit 4 (user block 0 e/w enable bit) of the flash memory control register 2 (address 0fe2 16 ) and this bit as shown in table 16, e/w is disabled to user block in the cpu rewriti ng mode. bit 3 of the flash memory contro l register 0 is the flash memory reset bit used to reset the control circuit of internal flash memory. this bit is used when flash me mory access has failed. when the cpu rewrite mode select bit is ?1?, setting ?1? for this bit resets the control circuit. to release the reset, it is necessary to set this bit to ?0?. bit 5 of the flash memory control register 0 is the user rom area select bit and is valid only in the boot mode. setting this bit to ?1? in the boot mode switches an accessible area from the boot rom area to the user rom area. to use the cpu rewrite mode in the boot mode, set this bit to ?1 ?. to rewrite bit 5, execute the user original reprogramming control software transferred to the internal ram in advance. bit 6 of the flash memory control register 0 is the program status flag. this bit is set to ?1? when writing to flash memory is failed. when program error occurs, the block cannot be used. bit 7 of the flash memory contro l register 0 is the erase status flag. this bit is set to ?1? when erasing flash memory is failed. when erase error occurs, the block cannot be used. figure 72 shows the flash me mory control register 1. bit 0 of the flash memory control register 1 is the erase suspend enable bit. by setting this bit to ?1?, the erase suspend mode to suspend erase processing tempor ary when block erase command is executed can be used. in order to set this bit 0 to ?1?, writing ?0? and ?1? in succession to bit 0. in order to set this bit to ?0?, write ?0? only to bit 0. bit 1 of the flash memory control register 1 is the erase suspend request bit. by setting this bit to ?1? when erase suspend enable bit is ?1?, the erase processing is suspended. bit 6 of the flash memory control register 1 is the erase suspend flag. this bit is cleared to ?0? at the flash erasing. fig 71. structure of flash memory control register 0 fig 72. structure of flash memory control register 1 flash memory control register 0 (fmcr0: address : 0fe0 16 , initial value: 01 16 ) ry/by status flag 0 : busy (being written or erased) 1 : ready cpu rewrite mode select bit (1) 0 : cpu rewrite mode invalid 1 : cpu rewrite mode valid user block 1 e/w enable bit (1, 2) 0 : e/w disabled (1800 16 -7fff 16 ) 1 : e/w enabled (1800 16 -7fff 16 ) flash memory reset bit (3, 4) 0 : normal operation 1 : reset not used (do not wri te 1 to this bit.) user rom area select bit (5) 0 : boot rom area is accessed 1 : user rom area is accessed program status flag 0: pass 1: error erase status flag 0: pass 1: error b7 b0 notes 1 : for this bit to be set to 1, the user needs to write a 0 a nd then a 1 to it in succession. for this bit to be set to 0, write 0 only to this bit. 2 : this bit can be written only when cpu rewrite mode select bit is 1. 3 : effective only when the cpu rewrite mode select bit = 1. fi x this bit to 0 when the cpu rewrite mode select bit is 0. 4 : when setting this bit to 1 (when the control circuit of fla sh memory is reset), the flash memory cannot be accessed for 10 s. 5 : write to this bit in program on ram flash memory control register 1 (fmcr1: address: 0fe1 16 , initial value: 40 16 ) erase suspend enable bit (1) 0 : suspend invalid 1 : suspend valid erase suspend request bit (2) 0 : erase restart 1 : suspend request not used (do not write 1 to this bit.) erase suspend flag 0 : erase active 1 : erase inactive (erase suspend mode) not used (do not write 1 to this bit.) b7 b0 notes 1 : for this bit to be set to 1, the user needs to write a 0 and then a 1 to it in succession. for this bit to be set to 0, write 0 only to this bit. 2 : effective only when the suspend enable bit = 1.
rev.3.02 apr 10, 2008 page 74 of 131 rej03b0177-0302 38d2 group fig 73. structure of flash memory control register 2 figure 74 shows a flowchart for se tting/releasing cp u rewrite mode. fig 74. cpu rewrite mode set/release flowchart be sure to execute flash memory control register 2 (fmcr2: address : 0fe2 16 , initial value: 45 16 ) not used (return ?1? when read) not used (do not write ?1? to this bit.) not used (return ?1? when read) not used (return ?0? when read) user block 0 e/w enable bit (1, 2) 0 : e/w disabled (8000 16 -ffff 16 ) 1 : e/w enabled (8000 16 -ffff 16 ) not used (return ?0? when read) not used (return ?1? when read) not used (return ?0? when read) b7 b0 notes 1 : for this bit to be set to ?1?, the user needs to write a ?0? and then a ?1? to it in succession. for this bit to be set to ?0?, write ?0? only to this bit. 2 : effective only when the cpu rewrite mode select bit = ?1?. table 16 state of e/w inhibition function user block 0 e/w enable bit user block 1 e/w enable bit user block 0 addresses 8000 16 to ffff 16 user block 1 addresses 1800 16 to 7fff 16 data block addresses 1000 16 to 17ff 16 0 0 e/w disabled e/w disabled e/w enabled 0 1 e/w disabled e/w enabled e/w enabled 1 0 e/w enabled e/w disabled e/w enabled 1 1 e/w enabled e/w enabled e/w enabled start single-chip mode or boot mode set cpu mode register (1) jump to control program transferred to internal ram (subsequent operations are executed by control program in this ram) transfer cpu rewrite mode control program to internal ram set cpu rewrite mode select bit to ?1? (by writing ?0? and then ?1? in succession) using software command executes erase, program, or other operation end write ?0? to cpu rewrite mode select bit set user block 0 e/w enable bit to ?1? (by writing ?0? and then ?1? in succession) set user block 1 e/w enable bit (at e/w disabled; writing ?0? , at e/w enabled; writing ?0? and then ?1? in succession execute read array command (2) set user block 0 e/w enable bit to ?0? set user block 1 e/w enable bit to ?0? notes 1 : set the main clock as follows depending on the clock division ratio selection bits of cpu mode register (bits 6, 7 of address 003b 16 ). 2 : before exiting the cpu rewrite mode after completing erase or program operation, always be sure to execute the read array comm and.
rev.3.02 apr 10, 2008 page 75 of 131 rej03b0177-0302 38d2 group take the notes described below when rewriting the flash memory in cpu rewrite mode. (1) operation speed during cpu rewrite mode, set the system clock to 4.0 mhz or less using the main clock division ratio selection bits (bits 6 and 7 of address 003b 16 ). (2) instructions inhi bited against use the instructions which refer to the internal data of the flash memory cannot be used during cpu rewrite mode. (3) interrupts the interrupts cannot be used dur ing cpu rewrite mode because they refer to the internal data of the flash memory. (4) watchdog timer if the watchdog timer has been al ready activated, internal reset due to an underflow will not oc cur because the watchdog timer is surely cleared during program or erase. (5) reset reset is always valid. the mcu is activated using the boot mode at release of reset in the condition of cnv ss = ?h?, so that the program will begin at the address which is stored in addresses fffc 16 and fffd 16 of the boot rom area.
rev.3.02 apr 10, 2008 page 76 of 131 rej03b0177-0302 38d2 group software commands table 17 lists the so ftware commands. after setting the cpu rewrite mode select bit to ?1?, execute a software command to specify an erase or program operation. each software command is explained below. ? read array command (ff 16 ) the read array mode is entere d by writing the command code ?ff 16 ? in the first bus cycle. when an address to be read is input in one of the bus cycles that follow, the contents of the specified address are read out at the data bus (d 0 to d 7 ). the read array mode is retained until another command is written. ? read status register command (70 16 ) when the command code ?70 16 ? is written in the first bus cycle, the contents of the status register are read out at the data bus (d 0 to d 7 ) by a read in the second bus cycle. the status register is expl ained in the next section. ? clear status register command (50 16 ) this command is used to clear th e bits sr4 and sr5 of the status register after they have been set. these bits indicate that operation has ended in an error. to use this command, write the command code ?50 16 ? in the first bus cycle. ? program command (40 16 ) program operation starts when the command code ?40 16 ? is written in the first bus cycle. th en, if the address and data to program are written in the 2nd bus cycle, program operation (data programming and veri fication) will start. whether the write operation is completed can be confirmed by read status register or the ry/by status flag. to read the status register, write the read status register command ?70 16 ?. the status register bit 7 (sr7) is set to ?0? at the same time the program starts and returned to ?1? upon completion of the program. the read status mode remains active until the read array command (?ff 16 ?) is written. the ry/by status flag is set to ?0? during program operation and ?1? when the program operati on is completed as is the status register bit 7 (sr7). at program end, program result s can be checked by reading the status register. fig 75. program flowchart notes: 1. srd = status register data 2. wa = write address, wd = write data 3. ba = block address to be erased (input the maximum address of each block.) 4. x denotes a given address in the user rom area. start write ?40 16 ? sr7 = ? 1 ? ? or ry/by = ? 1 ? ? read status register program completed no yes write write address write data sr4 = ?0?? program error no yes table 17 list of software commands (cpu rewrite mode) command cycle number first bus cycle second bus cycle mode address data (d 0 to d 7 ) mode address data (d 0 to d 7 ) read array 1 write x (4) ff 16 read status register 2 write x 70 16 read x srd (1) clear status register 1 write x 50 16 program 2 write x 40 16 write wa (2) wd (2) block erase 2 write x 20 16 write ba (3) d0 16
rev.3.02 apr 10, 2008 page 77 of 131 rej03b0177-0302 38d2 group ? block erase command (20 16 /d0 16 ) by writing the command code ?20 16 ? in the first bus cycle and the confirmation command code ?d0 16 ? and the block address in the second bus cycle that follows, the block erase (erase and erase verify) operation starts for the block address of the flash memory to be specified. whether the block erase operation is completed can be confirmed by read status register or the ry/by status flag of flash memory control register. to read the st atus register, write the status register command ?70 16 ?. the status register bit 7 (sr7) is set to ?0? at the same time the block erase operation starts and returned to ?1? upon completi on of the block erase operation. the read status mode at this time remains active until the read array command (?ff 16 ?) is written. the ry/by status flag register is set to ?0? during block erase operation and ?1? when the block erase operation is completed as is the status regi ster bit 7 (sr7). after the block erase ends, er ase results can be checked by reading the status register. for de tails, refer to the section where the status register is detailed. fig 76. erase flowchart write 20 16 write d0 16 block address read status register sr7 = 1 ? or ry/by = 1 ? erase completed (write read command ff 16 ) no yes start sr5 = 0? erase error yes no
rev.3.02 apr 10, 2008 page 78 of 131 rej03b0177-0302 38d2 group ? status register the status register shows the operating status of the flash memory and whether erase op erations and programs ended successfully or in error. it ca n be read in the following ways: (1) by reading an arbitrary address from the user rom area after writing the read stat us register command (70 16 ) (2) by reading an arbitrary addr ess from the user rom area in the period from when the program starts or erase operation starts to when the read array command (ff 16 ) is input. also, the status register can be cleared by writing the clear status register command (50 16 ). after reset, the status register is set to ?80 16 ?. table 18 shows the status register. each bit in this register is explained below. ? sequencer status (sr7) the sequencer status indicates th e operating status of the flash memory. this bit is set to ?0 ? (busy) during write or erase operation and is set to ?1? when these ope rations ends. after power-on, the sequencer st atus is set to ?1? (ready). ? erase status (sr5) the erase status indicates the ope rating status of erase operation. if an erase error occurs, it is set to ?1?. when the erase status is cleared, it is reset to ?0?. ? program status (sr4) the program status indicates th e operating status of write operation. when a write error occurs, it is set to ?1?. the program status is reset to ?0? when it is cleared. if ?1? is written for any of the sr5 and sr4 bits, the read array, program, and block erase commands are not accepted. before executing these commands, execute the clear status register command (50 16 ) and clear the status register. also, if any commands are not correct, both sr5 and sr4 are set to ?1?. table 18 definition of each bit in status register each bit of srd bits status name definition ?1? ?0? sr7 (bit7) sequencer status ready busy sr6 (bit6) reserved ?? sr5 (bit5) erase status terminated in error terminated normally sr4 (bit4) program status terminated in error terminated normally sr3 (bit3) reserved ?? sr2 (bit2) reserved ?? sr1 (bit1) reserved ?? sr0 (bit0) reserved ??
rev.3.02 apr 10, 2008 page 79 of 131 rej03b0177-0302 38d2 group full status check by performing full status check, it is possible to know the execution results of erase and program operations. figure 77 shows a full status check flowch art and the action to be taken when each error occurs. fig 77. full status check flowchart and remedial procedure for errors read status register sr4 = 1 and sr5 = 1? command sequence error yes execute the clear status register command (50 16 )to clear the status register. try performing the operation one more time after confirming that the command is entered correctly. no sr5 = 0? yes block erase error no should an erase error occur, the block in error cannot be used. sr4 = 0? yes program error no end (block erase, program) note: when one of sr5 and sr4 is set to 1, none of the read array, program, and block erase commands is accepted. execute the clear status register command (50 16 ) before executing these commands. should a program error occur, the block in error cannot be used.
rev.3.02 apr 10, 2008 page 80 of 131 rej03b0177-0302 38d2 group functions to inhibit rewriting flash memory version to prevent the contents of inte rnal flash memory from being read out or rewritten easily, this mcu incorporates a rom code protect function for use in parallel i/o mode and an id code check function for use in standard serial i/o mode. ? rom code protect function the rom code protect function is the function to inhibit reading out or modifying the contents of internal flash memory by using the rom code protect control address (address ffdb 16 ) in parallel i/o mode. figure 78 shows the rom code protect control address (address ffdb 16 ). (this address exists in the user rom area.) if one or both of the pair of ro m code protect bits is set to ?0?, the rom code protect is turned on, so that the contents of internal flash memory are protected against readout and modification. the ro m code protect is implemented in two levels. if level 2 is selected, the flash memory is protected even against readout by a shipment insp ection lsi tester , etc. when an attempt is made to select both level 1 and level 2, level 2 is selected by default. if both of the two rom code protect reset bits are set to ?00?, the rom code protect is turned off, so that the contents of internal flash memory can be readout or modified. once the rom code protect is turned on, the contents of the rom code protect reset bits cannot be modified in para llel i/o mode. use standard serial i/o mode or other modes to rewrite the contents of the rom code protect disable bits. rewriting of only the rom code protect control address (address ffdb 16 ) cannot be performed. wh en rewriting the rom code protect reset bit, rewrite the whole user rom area (block 0) containing the rom code protect control address. fig 78. structure of rom code protect control address rom code protect control address (address ffdb 16 ) romcp (ff 16 when shipped) reserved bits (1 at read/write) rom code protect level 2 set bits (romcp2) (1, 2) b3b2 0 0: protect enabled 0 1: protect enabled 1 0: protect enabled 1 1: protect disabled rom code protect reset bits (romcr) (3) b5b4 0 0: protect removed 0 1: protect set bits effective 1 0: protect set bits effective 1 1: protect set bits effective rom code protect level 1 set bits (romcp1) (1) b7b6 0 0: protect enabled 0 1: protect enabled 1 0: protect enabled 1 1: protect disabled b7 1 1 b0 notes 1 : when rom code protect is turned on, the internal flash memory is protected against readout or modification in parallel i/o mode. 2 : when rom code protect level 2 is turned on, rom code readout by a shipment inspection lsi tester, e tc. also is inhibited. 3 : the rom code protect reset bit s can be used to turn off rom c ode protect level 1 and rom code protect level 2. however, no change can be made in parallel i/o mode. use serial i/o mode or other modes to change settings.
rev.3.02 apr 10, 2008 page 81 of 131 rej03b0177-0302 38d2 group ? id code check function use this function in standard se rial i/o mode. when the contents of the flash memory are not blank, the id code sent from the programmer is compared with the id code written in the flash memory to see if they match. if the id codes do not match, the commands sent from the programmer are not accepted. the id code consists of 8-bit data, and its areas are ffd4 16 to ffda 16 . write a program which has had the id code preset at these addresses to the flash memory. fig 79. id code store addresses id7 id6 id5 id4 id3 id2 id1 address rom code protect control interrupt vector area ffd5 16 ffd4 16 ffd6 16 ffd7 16 ffd8 16 ffd9 16 ffda 16 ffdb 16
rev.3.02 apr 10, 2008 page 82 of 131 rej03b0177-0302 38d2 group parallel i/o mode the parallel i/o mode is used to input/output software commands, address and data in parallel for operation (read, program and erase) to internal flash memory. ? user rom and boot rom areas in parallel i/o mode, the user rom and boot rom areas shown in figure 70 can be rewritten. bo th areas of flash memory can be operated on in the same way. the boot rom area is 4 kbytes in size and located at addresses f000 16 through ffff 16 . make sure program and block erase operations are always performed within this address range. (access to any location outside this address range is prohibited.) in the boot rom area, an eras e block operation is applied to only one 4 k byte block. the boot rom area has had a standard serial i/o mode control program stored in it when shipped from the factory. therefore, using th e mcu in standard serial i/o mode, do not rewrite to the boot rom area.
rev.3.02 apr 10, 2008 page 83 of 131 rej03b0177-0302 38d2 group standard serial i/o mode the standard serial i/o mode inputs and outputs the software commands, addresses a nd data needed to ope rate (read, program, erase, etc.) the internal flash memory. this i/o is clock synchronized serial. this m ode requires a purpose-specific peripheral unit. the standard serial i/o mode is different from the parallel i/o mode in that the cpu controls flash memory re write (uses the cpu rewrite mode), rewr ite data input and so forth. the standard serial i/o mode is started by connecting ?h? to the cnv ss pin and ?h? to the p3 2 (bootent) pin, and releasing the reset operation. (in the ordinary microcomputer mode, set cnv ss pin to ?l? level.) this control program is written in the boot rom area when the product is shipped from renesas. accordingly, make note of the fact that the st andard serial i/o mode cannot be used if the boot rom area is re written in parallel i/o mode. the standard serial i/ o mode has st andard serial i/o mode 1 of the clock synchronous serial and standa rd serial i/o mode 2 of the clock asynchronous serial. tables 19 and 20 show description of pin function (standard serial i/o mode). figure 80 to 82 show the pin connections for the st andard serial i/o mode. in standard serial i/o mode, only the user rom area shown in figure 70 can be rewritten. the boot rom area cannot be written. in standard serial i/o mode, a 7- byte id code is used. when there is data in the flash memory, this function determines whether the id code sent from the peripheral unit (programmer) and those written in the flash memory match. the commands sent from the peripheral unit (programmer) are not accepted unless the id code matches.
rev.3.02 apr 10, 2008 page 84 of 131 rej03b0177-0302 38d2 group table 19 description of pin function (flash memory standard serial i/o mode 1) pin name signal name i/o function v cc ,v ss power supply i apply 2.7 to 5.5 v to the v cc pin and 0 v to the vss pin. cnv ss cnv ss i after input of port is set, input ?h? level. reset reset input i reset input pin. to reset the microcomputer, reset pin should be held at an ?l? level for 16 cycles or more of x in . x in clock input i connect an oscillation circuit between the x in and x out pins. as for the connection method, refer to the ?clock generating circuit?. x out clock output o av ss analog power supply input connect avss to v ss . v ref reference voltage input i apply reference voltage of a/d convertor to this pin. p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 , p3 4 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 i/o port i/o input ?l? or ?h? level, or keep open. p3 3 rxd input i serial data input pin. p3 2 txd output o serial data output pin. p3 1 s clk input i serial clock input pin. p3 0 busy output o busy signal output pin. table 20 description of pin function (flash memory standard serial i/o mode 2) pin name signal name i/o function v cc ,v ss power supply i apply 2.7 to 5.5 v to the vcc pin and 0 v to the v ss pin. cnv ss cnv ss i after input of port is set, input ?h? level. reset reset input i reset input pin. to reset the microcomputer, reset pin should be held at an ?l? level for 16 cycles or more of x in . x in clock input i connect an oscillation circuit between the x in and x out pins. as for the connection method, refer to the ?clock generating circuit?. x out clock output o av ss analog power supply input connect avss to v ss . v ref reference voltage input i apply reference voltage of a/d convertor to this pin. p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 , p3 4 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 i/o port i/o input ?l? or ?h? level, or keep open. p3 3 rxd input i serial data input pin. p3 2 txd output o serial data output pin. p3 1 s clk input i input ?l? level. p3 0 busy output o busy signal output pin.
rev.3.02 apr 10, 2008 page 85 of 131 rej03b0177-0302 38d2 group fig 80. connection for standard serial i/o mode 1 package type: plqp0064ga-a (64p6u-a)/plqp0064kb-a (64p6q-a) p0 6 /seg 6 p0 7 /seg 7 p1 0 /seg 8 p1 1 /seg 9 p1 2 /seg 10 p1 3 /seg 11 p1 4 /seg 12 p1 5 /seg 13 p1 6 /seg 14 p1 7 /seg 15 61 32 31 30 29 28 27 26 25 24 23 22 21 6 7 8 9 10111213141516 45 44 43 42 41 40 39 38 37 36 35 34 33 p2 4 /seg 20 p2 5 /seg 21 com 2 com 1 com 0 p2 7 /seg 23 /v l2 p2 6 /seg 22 /v l1 com 3 p0 3 /seg 3 /(kw 7 ) p 0 4 / s e g 4 p0 5 /seg 5 p5 1 /int 1 p5 6 /s clk1 /(kw 2 ) p5 5 /t x d 1 /(kw 1 ) p5 4 /r x d 1 /(kw 0 ) p5 3 /t 4out /pwm 1 p2 0 /seg 16 p2 1 /seg 17 p2 2 /seg 18 p2 3 /seg 19 49 50 51 52 53 48 47 46 62 63 64 12345 20 19 18 17 55 56 57 58 59 60 M38D29fffp/hp 54 p3 6 /t 2out /ckout/(led 6 ) p5 2 /t 3out /pwm 0 vref v l3 p4 7 /rtp 1 /an 7 p4 6 /rtp 0 /an 6 p3 2 /t x d 2 /(led 2 ) p3 1 /s clk2 /(led 1 ) p3 3 /r x d 2 /(led 3 ) p5 0 /int 0 av ss p0 2 /seg 2 /(kw 6 ) p0 1 /seg 1 /(kw 5 ) p0 0 /seg 0 /(kw 4 ) p5 7 /s rdy1 /(kw 3 ) p3 5 /t xout1 /(led 5 ) p3 4 /int 2 /(led 4 ) p3 0 /s rdy2 /(led 0 ) p6 0 /cntr 1 p3 7 /cntr 0 /t xout2 /(led 7 ) x out p4 3 /an 3 p4 2 /an 2 /adkey p4 4 /an 4 p4 5 /an 5 v ss p4 1 /o out1 /an 1 p4 0 /o out0 /an 0 p6 2 /x cout p6 1 /x cin v cc x in reset gnd v pp reset vcc * cnvss *connect oscillation circuit. indicates flash memory pin. s clk busy txd rxd
rev.3.02 apr 10, 2008 page 86 of 131 rej03b0177-0302 38d2 group fig 81. when using programmer (in standard serial i/o mode 1) of suisei electronics system co., ltd, connection example 38d2 group set the same termination as the single-chip mode. vcc p3 1 (s clk ) p3 0 (busy) reset vss avss x in x out note 1: for the programmer circuit, the wiring capacity of each signal pin m ust not exceed 47pf. cnv ss t_vdd t_vpp t_sclk t_busy reset circuit t_reset gnd 4.7 k t_pgm/oe/md p3 3 (rxd) t_txd 4.7 k t_rxd p3 2 (txd) flash memory version n.c.
rev.3.02 apr 10, 2008 page 87 of 131 rej03b0177-0302 38d2 group fig 82. when using e8 programmer (in standard serial i/o mode 1) connection example 38d2 group reset circuit vcc p3 2 (txd) p3 1 (s clk ) p3 0 (busy) reset vss avss x in x out 4.7 k * 1: open-collector buffer note 1: for the programmer circuit, the wiring capacity of each signal pin m ust not exceed 47pf. vcc 14 12 10 8 13 9 7 4 2 6 3 1 *1 cnv ss 4.7 k 11 p3 3 (rxd) set the same termination as the single-chip mode. 4.7 k 5 flash memory version
rev.3.02 apr 10, 2008 page 88 of 131 rej03b0177-0302 38d2 group fig 83. operating waveform for standard serial i/o mode 1 fig 84. operating waveform for standard serial i/o mode 2 power source reset cnv ss p3 2 (t x d) p3 1 (s clk ) p3 0 (busy) p3 3 (r x d) td(cnv ss -reset) td(p3 2 -reset) notes: in the standard serial i/o mode 1, input ?h? to the p3 1 pin. be sure to set the cnvss pin to ?h? before rising reset. be sure to set the p3 2 pin to ?h? before rising reset. td(cnv ss -reset) td(p3 2 -reset) symbol min. max. typ. unit 0 0 -- ms ms limits flash memory version power source reset cnv ss p3 2 (t x d) p3 0 (busy) p3 3 (r x d) p3 1 (s clk ) td(cnv ss -reset) td(p3 2 -reset) td(cnv ss -reset) td(p3 2 -reset) symbol min. max. typ. unit 0 0 -- ms ms limits notes: in the standard serial i/o mode 2, input ?h? to the p3 1 pin. be sure to set the cnvss pin to ?h? before rising reset. be sure to set the p3 2 pin to ?h? before rising reset. flash memory version
rev.3.02 apr 10, 2008 page 89 of 131 rej03b0177-0302 38d2 group notes on use processor status register the contents of the processor status register (ps) after a reset are undefined, except for the interrupt disable flag (i) which is ?1?. after a reset, initialize flags which affect program execution. in particular, it is essential to initialize the inde x x mode (t) and the decimal mode (d) flags because of their effect on calculations. initialize these fl ags at biginning of the program. interrupt the contents of the interrupt request bits do not change immediately after they have be en written. after writing to an interrupt request register, execut e at least one instruction before performing a bbc or bbs instruction. decimal calculations ? to calculate in decima l notation, set the de cimal mode flag (d) to ?1?, then execute an adc or sbc instruction. after executing an adc or sbc instru ction, execute at least one instruction before executing a sec, clc, or cld instruction. ? in decimal mode, the values of the negative (n), overflow (v), and zero (z) flags are invalid. timers the division ratio is 1/(n+1) when the value n (0 to 255) is written to the timer latch. multiplication and division instructions the index mode (t) and the deci mal mode (d) flags do not affect the mul and div instruction. the execution of these instructi ons does not change the contents of the processor status register. direction registers the values of the port direction registers cannot be read. this means, it is impossible to use the lda instruction, memory operation instruction when the t flag is ?1?, addressing mode using direction register values as qualifiers, and bit test instructions such as bbc and bbs. it is also impossible to use bit operation instructions such as clb and seb, and read-modify- write instructions to direction registers, including calculations such as ror. to set the direction registers, use instructions such as ldm or sta. serial interface in clock synchronous serial i/o, if the receive side is using an external clock and it is to output the s rdy signal, set the transmit enable bit, the receive enable bit, and the s rdy output enable bit to ?1?. serial i/o continues to out put the final bit from the t x d pin after transmission is completed. a/d converter the comparator is constructe d linked to a capacitor. the conversion accuracy may be low beca use the charge is lost if the conversion speed is not en ough. accordingly, set f(x in ) to at least 500khz during a/d conversion in the x in mode. also, do not execute the stp or wit instruction during an a/d conversion. in the low-speed mode, since th e a/d conversion is executed by the on-chip oscillator, the minimum value of f(x in ) frequency is not limited. lcd drive control circuit execution of the stp instruction sets the lcd enable bit (bit 3 of the lcd mode register) and bits 0 to 5 and bit 7 of the lcd power control register to ?0? and the lcd panel turns off. to make the lcd panel turn on after returning from the stop mode, set these bits to ?1?. instruction execution time the instruction execution time is obtained by multiplying the frequency of the internal clock by the number of cycles needed to execute an instruction. power source voltage when the power source voltage va lue of a microcomputer is less than the value which is indicat ed as the recommended operating conditions, the microc omputer does not operate normally and may perform unstable operation. in a system where the power source voltage drops slowly when the power source voltage drops or the power supply is turned off, reset a microcomputer when the power source voltage is less than the recommended operating conditions and design a system not to cause errors to the sy stem by this unstable operation. handling of power source pin in order to avoid a latch-up occurrence, connect a capacitor suitable for high frequencies as bypass capacitor between power source pin (v cc pin) and gnd pin (vss pin), and between power source pin (v cc pin) and analog power source pin (av cc ). besides, connect the capacitor to as close as possible. for bypass capacitor which should not be loca ted too far from the pins to be connected, a ceramic capacitor of 0.1 f is recommended. lcd drive power supply power supply capacitor may be insufficient with the division resistance for lcd power supply, and the characteristic of the lcd panel. in this case, there is the method of connecting the bypass capacitor about 0.1 ? 0.33 f to v l1 ? v l3 pins. the example of a strengthening measure of the lcd drive power supply is shown below. fig. 85 strengthening measure example of lcd drive power supply ? connect by the shortest possible wiring. ? connect the bypass capacitor to the v l1 ? v l3 pins as short as possible. (referential value:0.1 ? 0.33 f) v l3 v l2 v l1
rev.3.02 apr 10, 2008 page 90 of 131 rej03b0177-0302 38d2 group notes on qzrom version wiring to oscsel pin 1. oscsel = l connect the oscsel pin the sh ortest possible to the gnd pattern which is supplied to the v ss pin of the microcomputer. in addition connecting an approximately 5 k resistor in series to the gnd could improve noise im munity. in this case as well as the above mention, connect the pin the shortest possible to the gnd pattern which is supplied to the v ss pin of the microcomputer. 2. oscsel = h connect the oscsel pin the sh ortest possible to the v cc pattern which is supplied to the v cc pin of the microcomputer. in addition connecting an approximately 5 k resistor in series to the v cc could improve noise immunity . in this case as well as the above mention, connect the pin the shortest possible to the v cc pattern which is supplied to the v cc pin of the microcomputer. ?reason the oscsel pin is the power source input pin for the built-in qzrom. when programming in the qzrom, the impedance of the oscsel pin is low to allow th e electric current for writing to flow into the built-in qzrom. b ecause of this, noise can enter easily. if noise enters the oscs el pin, abnormal instruction codes or data are read from the qzrom, which may cause a program runaway. fig. 86 wiring for the oscsel pin precautions regarding overvoltage in qzrom version make sure that voltage exceeding the v cc pin voltage is not applied to other pins. in particular , ensure that the state indicated by bold lines in figure below does not occur for oscsel pin (v pp power source pin for qzrom) during power-on or power- off. otherwise the contents of qzrom could be rewritten. fig. 87 example of overvoltage product shipped in blank as for the product shipped in blank, renesas does not perform the writing test to user rom area after the assembly process though the qzrom writing test is performed enough before the assembly process. therefore, a writing error of approximate 0.1% may occur. moreover, please note the contac t of cables and foreign bodies on a socket, etc. because a writing environment may cause some writing errors. notes on qzrom writing orders when ordering the qzrom product shipped after writing, submit the mask file (extension: .msk) which is made by the mask file converter mm. ? be sure to set the rom option data* setup when making the mask file by using the mask file converter mm.. the rom code protect is specified acco rding to the rom option data* in the mask file which is submitted at ordering. note that the mask file which has nothing at the rom option data* or has the data other than ?00 16 ?, ?fe 16 ? and ?ff 16 ? can not be accepted. ?set ?ff 16 ? to the rom code protect address in rom data regardless of the presence or ab sence of a protect. when data other than ?ff 16 ? is set, we may ask that the rom data be submitted again. * rom option data: mask option noted in mm data required for qzrom writing orders the following are necessary when ordering a qzrom product shipped after writing: 1. qzrom writing confirmation form* 2. mark specification form* 3. rom data...........mask file * for the qzrom writing confirmation form and the mark specification form, refer to th e ?renesas technology corp.? homepage (http://www.ren esas.com/homepage.jsp). note that we cannot deal with special font marking (customer's trademark etc.) in qzrom microcomputer. qzrom receive flow when writing to qzrom is performed by user side, the receiving inspection by the fo llowing flow is necessary. fig. 88 qzrom receive flow oscsel v ss the shortest the shortest about 5 k termination of oscsel pin oscsel v cc the shortest the shortest about 5 k (1) oscsel = l (2) oscsel = h (1) (1) (1) (1) note 1: it shows the microcomputers pin v cc pin voltage oscsel pin voltage ?h? input oscsel pin voltage ?l? input 1.8v 1.8v (1) input voltage to other mcu pins rises before v cc pin voltage. (2) input voltage to other mcu pins falls after v cc pin voltage. note: the internal circuitry is unstable when v cc is below the minimum voltage specification of 1.8 v (shaded portion), so particular care should be exercised regarding overvoltage. (1) (2) qzrom product shipped in blank programming verify test receiving inspection of unprotected area (verify test) programming to unprotected area verify test for unprotected area shipping user qzrom product shipped after writing ?protect disabled? ?protect enabled to the protect area 1? renesas receiving inspection (blank check) programming verify test for all area shipping user renesas
rev.3.02 apr 10, 2008 page 91 of 131 rej03b0177-0302 38d2 group notes on flash memory version cpu rewrite mode (1) operation speed during cpu rewrite mode , set the system clock 4.0 mhz or less using the main clock division ratio selection bits (bits 6 and 7 of address 003b 16 ). (2) instructions inhi bited against use the instructions which refer to the internal data of the flash memory cannot be used dur ing the cpu rewrite mode. (3) interrupts inhibited against use the interrupts cannot be used during the cpu rewrite mode because they refer to the internal data of the flash memory. (4) watchdog timer in case of the watchdog timer has been running already, the internal reset generated by watchdog timer underflow does not happen, because of watchdog timer is always clearing during program or erase operation. (5) reset reset is always vali d. in case of cnv ss = ?h? when reset is released, boot mode is active. so the program starts from the address contained in address fffc 16 and fffd 16 in boot rom area. cnv ss pin the cnv ss pin determines the flash memory mode. connect the cnv ss /v pp pin the shortest possible to the gnd pattern which is supplied to the v ss pin of the microcomputer. in addition connecting an approximately 5 k . resistor in series to the gnd could improve noise immunity. in this case as well as the above mention, connect the pi n the shortest possible to the gnd pattern which is supplied to the v ss pin of the microcomputer. note. when the boot mode or the stan dard serial i/o mode is used, a switch of the inpu t level to the cnv ss pin is required. fig 89. wiring for the cnv ss notes on differences between qzrom version and flash memory version the qzrom version and flash memo ry versions differ in their manufacturing processe s, built-in rom, an d layout patterns. because of these differences, characteristic values, operation margins, noise immunity, and noise radiation and oscillation circuit constants may vary within the specified range of electrical characteristics. when switching to the qzrom version, implement system evaluations equivalent to thos e performed in the flash memory version. confirm page 11 about the differences of functions. the shortest cnv ss v ss approx. 5k the shortest (1) (1) note 1: it shows the microcomputers pin.
rev.3.02 apr 10, 2008 page 92 of 131 rej03b0177-0302 38d2 group countermeasures against noise (1) shortest wiring length 1. wiring for reset pin make the length of wiring which is connected to the reset pin as short as possible. especi ally, connect a capacitor across the reset pin and the v ss pin with the shortest possible wiring (within 20 mm). ?reason the width of a pulse input into the reset pin is determined by the timing necessary conditions. if noise having a shorter pulse width than the standard is input to the reset pin, the reset is released before the internal state of the microcomputer is completely initialized. this may cause a program runaway. fig. 90 wiring for the reset pin 2. wiring for clock input/output pins ? make the length of wiring whic h is connected to clock i/o pins as short as possible. ? make the length of wiring (within 20 mm) across the grounding lead of a capacitor which is connected to an oscillator and the v ss pin of a microcomputer as short as possible. ? separate the v ss pattern only for osc illation from other v ss patterns. ?reason if noise enters clock i/o pins, clock waveforms may be deformed. this may cause a program failure or program runaway. also, if a potential difference is cause d by the noise between the v ss level of a microcomputer and the v ss level of an oscillator, the correct clock will not be input in the microcomputer. fig. 91 wiring for clock i/o pins (2) connection of bypass capacitor across v ss line and v cc line in order to stabilize the system operation and avoid the latch-up, connect an approximately 0.1 f bypass capacitor across the v ss line and the v cc line as follows: ? connect a bypass capacitor across the v ss pin and the v cc pin at equal length. ? connect a bypass capacitor across the v ss pin and the v cc pin with the shortest possible wiring. ? use lines with a larger diameter than other signal lines for v ss line and v cc line. ? connect the power source wiring via a bypass capacitor to the v ss pin and the v cc pin. fig. 92 bypass capacitor across the v ss line and the v cc line reset reset circuit noise v ss v ss n.g. reset circuit v ss reset v ss o.k. noise x in x out v ss n.g. x in x out v ss o.k. v ss v cc v ss v cc n.g. o.k.
rev.3.02 apr 10, 2008 page 93 of 131 rej03b0177-0302 38d2 group (3) oscillator concerns in order to obtain the stabiliz ed operation clock on the user system and its condition, contact the oscillator manufacturer and select the oscillator and oscillation circuit constants. be careful especially when range of volta ge and temperature is wide. also, take care to prevent an osci llator that generates clocks for a microcomputer operation from bei ng affected by other signals. 1. keeping oscillator away fr om large current signal lines install a microcomputer (and especially an oscillator) as far as possible from signal lines wher e a current larger than the tolerance of current value flows. ?reason in the system using a microcom puter, there are signal lines for controlling motors, leds, and ther mal heads or others. when a large current flows through those signal lines, strong noise occurs because of mutual inductance. 2. installing osc illator away from signa l lines where potential levels change frequently install an oscillator and a conne cting pattern of an oscillator away from signal lines wh ere potential levels change frequently. also, do not cross such signal lines over the clock lines or the signal lines wh ich are sensitive to noise. ?reason signal lines where potenti al levels change fre quently (such as the cntr pin signal line) may affect other lines at signal rising edge or falling edge. if such line s cross over a clock line, clock waveforms may be deformed, which causes a microcomputer failure or a program runaway. fig. 93 wiring for a large current signal line/wiring of signal lines where potential levels change frequently (4) analog input the analog input pin is connected to the capacitor of a voltage comparator. accordingly, sufficient accuracy may not be obtained by the charge/discharge current at the time of a/d conversion when the analog signal source of high-impedance is connected to an analog input pin. in order to obtain the a/d conversion result stabilized more , please lower the impedance of an analog signal source, or a dd the smoothing capacitor to an analog input pin. (5) difference of memory size when memory size differ in one group, actual values such as an electrical characteristics, a/d conversion accuracy, and the amount of proof of noise incorre ct operation may differ from the ideal values. when these products are us ed switching, perform system evaluation for each product of every after confirming product specification. x in x out v ss m microcomputer mutual inductance large current gnd x in x out v ss cntr do not cross. n.g. 1. keeping oscillator away from large current signal lines 2. installing oscillator away from signal lines where potential levels change frequently
rev.3.02 apr 10, 2008 page 94 of 131 rej03b0177-0302 38d2 group qzrom version electrical characteristics absolute maximum ratings table 21 absolute maximum ratings symbol parameter conditions ratings unit v cc power source voltage all voltages are based on v ss . when an input voltage is measured, output transistors are cut off. ? 0.3 to 6.5 v v i input voltage p0 0 - p0 7 , p1 0 - p1 7 , p2 0 - p2 7 , p3 0 - p3 7 , p4 0 - p4 7 , p5 0 - p5 7 , p6 0 - p6 2 ? 0.3 to v cc +0.3 v v i input voltage v l1 ? 0.3 to v l2 v v i input voltage v l2 v l1 to v l3 v v i input voltage v l3 v l2 to 6.5 v v i input voltage reset , x in , oscsel ? 0.3 to v cc +0.3 v v o output voltage p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 at output port ? 0.3 to v cc +0.3 v at segment port ? 0.3 to v l3 +0.3 v v o output voltage com 0 -com 3 ? 0.3 to v l3 +0.3 v v o output voltage p3 0 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 ? 0.3 to v cc +0.3 v v o output voltage x out ? 0.3 to v cc +0.3 v p d power dissipation ta = 25 c300mw t opr operating temperature ? ? 20 to 85 c t stg storage temperature ? ? 40 to 125 c qzrom version
rev.3.02 apr 10, 2008 page 95 of 131 rej03b0177-0302 38d2 group recommended operating conditions notes: 1. when the a/d converter is used, refer to the recommended operating conditions of the a/d converter. 2. 12.5 mhz < f(x in ) 16 mhz is not available in the frequency/2 mode. 3. the oscillation start voltage and the oscillation start time di ffer depending on factors such as the oscillator, circuit cons tants, and operating temperature range. note that oscillation start may be pa rticularly difficult at low voltage when using a high-frequen cy oscillator. f: oscillation frequency (1 mhz f(x in ) 8 mhz) of oscillator. when the 8 mhz oscillation is used, assign ?8? to ?f?. table 22 recommended operating conditions (1) (v cc = 1.8 to 5.5 v, v ss = 0 v, ta = ? 20 to 85 c unless otherwise noted) symbol parameter limits unit min. typ. max. v cc power source voltage (1) frequency/2 mode (2) f(x in ) 12.5mhz 4.5 5.5 v f(x in ) 8.0mhz 4.0 5.5 v f(x in ) 4.0mhz 2.0 5.5 v f(x in ) 2.0mhz 1.8 5.5 v frequency/4 mode f(x in ) 16mhz 4.5 5.5 v f(x in ) 8.0mhz 2.0 5.5 v f(x in ) 4.0mhz 1.8 5.5 v frequency/8 mode f(x in ) 16mhz 4.5 5.5 v f(x in ) 8.0mhz 2.0 5.5 v f(x in ) 4.0mhz 1.8 5.5 v low-speed mode 1.8 5.5 v on-chip oscillator mode 1.8 5.5 v when start oscillating (3) 0.05 f + 1.9 v v ss power source voltage 0v v l3 lcd power source voltage 2.5 5.5 v v ref a/d converter reference voltage 2.0 v cc v av ss analog power source voltage 0 v v ia analog input voltage an 0 ? an 7 av ss v cc v v ih ?h? input voltage p0 4 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 , p3 0 , p3 2 , p3 5 , p3 6 , p4 0 ? p4 7 , p5 2 , p5 3 , p6 2 0.7v cc v cc v v ih ?h? input voltage p0 0 ? p0 3 , p3 1 , p3 3 , , p3 4 , p3 7 , p5 0 , 5 1 , p5 4 ? p5 7 , p6 0 , p6 1 0.8v cc v cc v v ih ?h? input voltage reset 2.2v < v cc 5.5v 0.8v cc v cc v v cc 2.2v 65 v cc ? 99 v cc ? 100 v cc v v ih ?h? input voltage x in 0.8v cc v cc v v il ?l? input voltage p0 4 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 , p3 0 , p3 2 , p3 5 , p3 6 , p4 0 ? p4 7 , p5 2 , p5 3 , p6 2 00.3v cc v v il ?l? input voltage p0 0 ? p0 3 , p3 1 , p3 3 , p3 4 , p3 7 , p5 0 , p5 1 , p5 4 ? p5 7 , p6 0 , p6 1 , oscsel 00.2v cc v v il ?l? input voltage reset 2.2v < v cc 5.5v 0 0.2v cc v v cc 2.2v 0 65 v cc ? 99 100 v v il ?l? input voltage x in 00.2v cc v qzrom version
rev.3.02 apr 10, 2008 page 96 of 131 rej03b0177-0302 38d2 group notes: 1. the total output current is the sum of all the currents flowi ng through all the applicable ports. the total average current i s an average value measured over 100 ms. the total peak current is the peak value of all the currents. 2. the peak output current is the peak current flowing in each port. 3. the average output current is average value measured over 100 ms. table 23 recommended operating conditions (3) (v cc = 1.8 to 5.5 v, v ss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter limits unit min. typ. max. ioh(peak) ?h? total peak output current (1) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 , p3 0 ? p3 7 ? 40 ma ioh(peak) ?h? total peak output current (1) p4 0 ? 4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 ? 40 ma iol(peak) ?l? total peak output current (1) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 40 ma iol(peak) ?l? total peak output current (1) p4 0 ? p4 7 , p5 0 , p5 1 , p5 4 ? p5 7 , p6 0 ? p6 2 40 ma iol(peak) ?l? total peak output current (1) p3 0 ? p3 7 , p5 2 , p5 3 110 ma ioh(avg) ?h? total average output current (1) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 , p3 0 ? p3 7 ? 20 ma ioh(avg) ?h? total average output current (1) p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 ? 20 ma iol(avg) ?l? total average output current (1) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 20 ma iol(avg) ?l? total average output current (1) p4 0 ? p4 7 , p5 0 , p5 1 , p5 4 ? p5 7 , p6 0 ? p6 2 20 ma iol(avg) ?l? total average output current (1) p3 0 ? p3 7 , p5 2 , p5 3 90 ma i oh(peak) ?h? peak output current (2) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 ? 2.0 ma i oh(peak) ?h? peak output current (2) p3 0 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 ? 5.0 ma i ol(peak) ?l? peak output current (2) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 5.0 ma i ol(peak) ?l? peak output current (2) p4 0 ? p4 7 , p5 0 , p5 1 , p5 4 ? p5 7 , p6 0 ? p6 2 10 ma i ol(peak) ?l? peak output current (2) p3 0 ? p3 7 , p5 2 , p5 3 30 ma i oh(avg) ?h? average output current (3) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 ? 1.0 ma i oh(avg) ?h? average output current (3) p3 0 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 ? 2.5 ma i ol(avg) ?l? average output current (3) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 2.5 ma i ol(avg) ?l? average output current (3) p4 0 ? p4 7 , p5 0 , p5 1 , p5 4 ? p5 7 , p6 0 ? p6 2 5.0 ma i ol(avg) ?l? average output current (3) p3 0 ? p3 7 , p5 2 , p5 3 15 ma qzrom version
rev.3.02 apr 10, 2008 page 97 of 131 rej03b0177-0302 38d2 group notes: 1. relationship between system clock frequency and power source voltage is shown in the graph below. 2. when the a/d converter is used, refer to the recommended operating conditions of the a/d converter. 3. 12.5 mhz < f(x in ) 16 mhz is not available in the frequency/2 mode. 4. the oscillation start voltage and the oscillation start time di ffer depending on factors such as the oscillator, circuit cons tants, and operation temperature range. note that oscillation start may be pa rticularly difficult at low voltage when using a high-frequen cy oscillator. 5. when using the microcomputer in low-speed mode, set t he clock input oscillation frequency on condition that f(x cin ) < f(x in )/3.
table 24 recommended operating conditions (4) (v cc = 1.8 to 5.5 v, v ss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter conditions limits unit min. typ. max. f(cntr 0 ) f(cntr 1 ) timer x and timer y input frequency (duty cycle 50%) 4.5 v cc 5.5v 6.25 mhz 4.0 v cc < 4.5v 2 vcc ? 4mhz 2.0 v cc < 4.0v vcc mhz v cc < 2.0v 5 vcc ? 8mhz f(tclk) timer x, timer y, timer 1, timer 2, timer 3, timer 4 clock input frequency (count source frequency of each timer) 4.5 v cc 5.5v 16 mhz 4.0 v cc < 4.5v 4 vcc ? 8mhz 2.0 v cc < 4.0v 2 vcc mhz v cc < 2.0v 10 vcc ? 16 mhz f( ) system clock frequency (1) 4.5 v cc 5.5v 6.25 mhz 4.0 v cc < 4.5v 4 mhz 2.0 v cc < 4.0v vcc mhz v cc < 2.0v 5 vcc ? 8mhz f(x in ) main clock input frequency (duty cycle 50%) (2)(3) 4.5 v cc 5.5v 1.0 16 mhz 2.0 v cc < 4.5v 1.0 8.0 mhz v cc < 2.0v 1.0 20 vcc ? 32 mhz f(x cin ) sub-clock oscillation frequency (duty cycle 50%) (4)(5) 32.768 80 khz system clock frequency [mhz] 6.25 4.0 2.0 1.0 0 1.8 2.0 4.0 4.5 5.5 [v] power source voltage main clock x in frequency [mhz] 16 8.0 4.0 1.0 0 1.8 2.0 4.5 5.5 [v] power source voltage qzrom version
rev.3.02 apr 10, 2008 page 98 of 131 rej03b0177-0302 38d2 group electrical characteristics note: 1. when the port xc switch bit (bit 4 of address 003b 16 ) of cpu mode register is ?1?, the drivability of p6 2 is different from the above. table 25 electrical characteristics (1) (v cc = 1.8 to 5.5 v, v ss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter test conditions limits unit min. typ. max. v oh ?h? output voltage p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 i oh = ? 2.5ma v cc ? 2.0 v i oh = ? 0.6ma v cc =2.5v v cc ? 1.0 v oh ?h? output voltage p3 0 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 (1) i oh = ? 5ma v cc ? 2.0 v i oh = ? 1.25ma v cc ? 0.5 i oh = ? 1.25ma v cc =2.5v v cc ? 1.0 v ol ?l? output voltage p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 i ol =5ma 2.0 v i ol =1.25ma 0.5 i ol =1.25ma v cc =2.5v 1.0 v ol ?l? output voltage p4 0 ? p4 7 , p5 0 , p5 1 , p5 4 ? p5 7 , p6 0 ? p6 1 (1) i ol =10ma 2.0 v i ol =2.5ma 0.5 i ol =2.5ma v cc =2.5v 1.0 v ol ?l? output voltage p3 0 ? p3 7 , p5 2 , p5 3 i ol =15ma 2.0 v i ol =3.0ma v cc =2.5v 0.8 v t+ ? v t ? hysteresis cntr 0 , cntr 1 , int 0 ? int 2 , kw 0 ? kw 7 0.5 v v t+ ? v t ? hysteresis r x d 1 , r x d 2 , s clk1 , s clk2 0.5 v v t+ ? v t ? hysteresis reset v cc = 2.0 v to 5.5 v on reset 0.5 v i ih ?h? input current p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 v i =v cc 5.0 a i ih ?h? input current p3 0 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 v i =v cc 5.0 a i ih ?h? input current reset , oscsel v i =v cc 5.0 a i ih ?h? input current x in v i =v cc 4.0 a i il ?l? input current p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 v i =v ss pull-up ?off? ? 5.0 a v cc =5.0v, v i =v ss pull-up ?on? ? 60 ? 120 ? 240 a v cc =3.0v, v i =v ss pull-up ?on? ? 25 ? 50 ? 100 a i il ?l? input current p3 0 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7, p6 0 ? p6 2 v i =v ss pull-up ?off? ? 5.0 a v cc =5.0v, v i =v ss pull-up ?on? ? 30 ? 70 ? 140 a v cc =3.0v, v i =v ss pull-up ?on? ? 6.5 ? 25 ? 45 a i il ?l? input current reset , oscsel v i =v ss ? 5.0 a i il ?l? input current x in v i =v ss ? 4.0 a f(oco) on-chip oscillator frequency v cc =5.0v, ta =25 c 2500 5000 7500 khz qzrom version
rev.3.02 apr 10, 2008 page 99 of 131 rej03b0177-0302 38d2 group a/d converter characteristics note: 1. confirm the recommended operating condition for main clock input frequency. table 26 electrical characteristics (2) (vcc = 1.8 to 5.5 v, v ss = 0 v, ta = ? 20 to 85 c, f(x cin ) = 32.768 khz, output transistors in the cut-off state, a/d converter stopped, unless otherwise noted) symbol parameter test conditions limits unit min. typ. max. v ram ram hold voltage when clock is stopped 1.8 5.5 v i cc power source current frequency/2 mode v cc =5.0v f(x in )=12.5mhz 6.4 13 ma f(x in )=12.5mhz (in wit state) 1.5 3.0 ma f(x in )=4mhz 2.2 3.0 ma v cc =2.5v f(x in )=4mhz 0.6 1.2 ma f(x in )=4mhz (in wit state) 0.3 0.6 ma f(x in )=2mhz 0.4 0.8 ma frequency/4 mode v cc =5.0v f(x in )=12.5mhz 3.5 10 ma f(x in )=12.5mhz (in wit state) 1.5 3.0 ma f(x in )=4mhz 1.5 2.5 ma v cc =2.5v f(x in )=8mhz 0.8 2.5 ma f(x in )=8mhz (in wit state) 0.3 0.6 ma f(x in )=4mhz 0.5 1.0 ma frequency/8 mode v cc =5.0v f(x in )=12.5mhz 2.5 5.0 ma f(x in )=12.5mhz (in wit state) 1.5 3.0 ma f(x in )=4mhz 1.2 1.6 ma v cc =2.5v f(x in )=8mhz 0.5 1.0 ma f(x in )=8mhz (in wit state) 0.3 0.6 ma f(x in )=4mhz 0.3 0.6 ma low-speed mode v cc =5.0v f(x in )=stop 17 26 a in wit state 5.5 11 a v cc =2.5v f(x in )=stop 7.0 14 a in wit state 3.5 7.0 a on-chip oscillator mode f(x in ), f(x cin ) = stop v cc =5.0v 270 540 a v cc =2.5v 35 90 a v cc =2.5v (in wit state) 25 75 a all oscillations stopped (in stp state) ta = 2 5 c 0.1 1.0 a ta = 8 5 c 10 a current increased at a/d converter operating f(x in )=12.5 mhz, v cc =5 v in frequency/2, 4 or 8 mode 0.5 ma f(x in )= stop, v cc = 5 v in on-chip oscillator operating 0.5 ma f(x in ) = stop, v cc = 5 v in low-speed mode 0.4 ma table 27 a/d converter recommended operating condition (vcc = 2.0 to 5.5 v, v ss = 0v, ta = ? 20 to 85 c, output transistors in cut-off state, unless otherwise noted) symbol parameter test conditions limits unit min. typ. max. v cc power source voltage 2.0 5.0 5.5 v v ih ?h? input voltage adkey 0.9v cc v cc v v il ?l? input voltage adkey 00.7 v cc ? 0.5 v f( ad ) ad converter clock frequency (1) (low-speed ? on-chip oscillator mode excluded) 4.5v < v cc 5.5v 6.25 mhz 4.0v < v cc 4.5v 4.0 mhz 2.0v < v cc 4.0v v cc mhz qzrom version
rev.3.02 apr 10, 2008 page 100 of 131 rej03b0177-0302 38d2 group notes: 1. tc( ad): one cycle of ad conversion clock. ad conversion clock can be selected from source/2 or source/8. source represents the x in input in the frequency/2, 4 or 8 mode and internal on-chip os cillator divided by 4 in the on-chip oscillator mode or the low-speed mode. when the a/d conversion is executed in the frequency/2 mode, frequency/4 mode, or frequency/8 mode, set f(x in ) 500 khz. relationship among ad conversion clock fre quency, power source voltage, ad conve rsion mode and ab solute accuracy. table 28 a/d converter characteristics (vcc = 2.0 to 5.5 v, ta = ? 20 to 85 c, output transistors in cut-off state, low-speed ? on-chip oscillator mode included, unless otherwise noted) symbol parameter test conditions limits unit min. typ. max. ? resolution 10 bits abs absolute accuracy (quantification error excluded) 10bitad mode 4.5v < v cc 5.5v, ad conversion clock = f(x in )/2, f(x in )/8 6.25mhz 4lsb 4.0v < v cc 4.5v, ad conversion clock = f(x in )/2, f(x in )/8 4mhz 2.2v v cc 4.0v, ad conversion clock =f(x in )/2, f(x in )/8 vccmhz 2.0v v cc 5.5v, ad conversion clock = f(oco)/8, f(oco)/32 8bitad mode 4.5v < v cc 5.5v, ad conversion clock = f(x in )/2, f(x in )/8 6.25mhz 2 4.0v < v cc 4.5v, ad conversion clock = f(x in )/2, f(x in )/8 4mhz 2.2v < v cc 4.0v, ad conversion clock =f(x in )/2, f(x in )/8 vccmhz 2.0v v cc 2.2v, ad conversion clock = f(x in )/2, f(x in )/8 (6vcc ? 11)mhz 2.0v v cc 2.2v, ad conversion clock = f(x in )/8 vccmhz 2.0v v cc 5.5v, ad conversion clock = f(oco)/8, f(oco)/32 t conv conversion time (1) 10bitad mode tc( ad) 61 tc( ad) 62 s 8bitad mode tc( ad) 49 tc( ad) 50 r ladder ladder resistor 12 35 100 k i vref reference input current v ref =5.0v 50 150 200 a i ia analog input current 5.0 a ad conversion clock frequency [mhz] 6.25 4.0 2.2 2.0 1.0 0 1.8 2.0 2.2 4.0 4.5 5.5 [v] power source voltage v cc note : f(x in ) 500khz f(x in )/2 or f(x in )/8 8bitad=2lsb f(x in )/ 8 8bitad=2lsb f(x in )/2 or f(x in )/8 10bitad=4lsb 8bitad=2lsb ad conversion clock ?frequency/2 mode, frequency/4 and frequency/8 mode: f(x in )/2 or f(x in )/8 10bitad=4lsb 8bitad=2lsb ad conversion clock ?low-speed mode and on-chip oscillator mode: f(oco)/8 or f(oco)/32 (note) qzrom version
rev.3.02 apr 10, 2008 page 101 of 131 rej03b0177-0302 38d2 group lcd power supply characteristics note: 1. the value is the average of each one division resistor. table 29 lcd power supply characteristics ( when connecting division resistors for lcd power supply ) (v cc = 1.8 to 5.5 v, v ss = 0 v, ta = ?20 to 85c, unless otherwise noted) symbol parameter test conditions limits unit min. typ. max. r lcd division resister for lcd power supply (1) rsel=?10? 200 k rsel=?11? 5 lcd drive timing a lcd circuit division ratio = divided by 1 rsel=?01? 120 rsel=?00? 90 lcd circuit division ratio = divided by 2 rsel=?01? 150 rsel=?00? 120 lcd circuit division ratio = divided by 4 rsel=?01? 170 rsel=?00? 150 lcd circuit division ratio = divided by 8 rsel=?01? 190 rsel=?00? 170 lcd drive timing b lcd circuit division ratio = divided by 1 rsel=?01? 150 rsel=?00? 120 lcd circuit division ratio = divided by 2 rsel=?01? 170 rsel=?00? 150 lcd circuit division ratio = divided by 4 rsel=?01? 190 rsel=?00? 170 lcd circuit division ratio = divided by 8 rsel=?01? 190 rsel=?00? 190 qzrom version
rev.3.02 apr 10, 2008 page 102 of 131 rej03b0177-0302 38d2 group timing requirements and switching characteristics notes: 1. 80 ns in the frequency/2 mode. 2. 32 ns in the frequency/2 mode. 3. when bit 6 of address 001a 16 , 001f 16 are ?1? (clock synchronous). divide this value by four when bit 6 of address 001a 16 , 001f 16 are ?0? (uart). note: 1. when bit 6 of address 001a 16 , 001f 16 are ?1? (clock synchronous). divide this value by four when bit 6 of address 001a 16 , 001f are ?0? (uart). table 30 timing requirements (1) (vcc = 4.0 to 5.5 v, vss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter limits unit min. typ. max. t w (reset) reset input ?l? pulse width 2 s t c (x in ) main clock input cycle time 4.5v v cc 5.5v (1) 62.5 ns 4.0v v cc < 4.5v 125 ns t wh (x in ) main clock input ?h? pulse width 4.5v v cc 5.5v (2) 25 ns 4.0v v cc < 4.5v 50 ns t wl (x in ) main clock input ?l? pulse width 4.5v v cc 5.5v (2) 25 ns 4.0v v cc < 4.5v 50 ns t c (cntr) cntr 0 , cntr 1 input cycle time 250 ns t wh (cntr) cntr 0 , cntr 1 input ?h? pulse width 105 ns t wl (cntr) cntr 0 , cntr 1 input ?l? pulse width 105 ns t wh (int) int 0 ? int 2 input ?h? pulse width 80 ns t wl (int) int 0 ? int 2 input ?l? pulse width 80 ns t c (s clk ) serial i/o1, 2 clock input cycle time (3) 800 ns t wh (s clk ) serial i/o1, 2 clock input ?h? pulse width (3) 370 ns t wl (s clk ) serial i/o1, 2 clock input ?l? pulse width (3) 370 ns t su (r x d-s clk ) serial i/o1, 2 input setup time 220 ns th(s clk- r x d) serial i/o1, 2 input hold time 100 ns table 31 timing requirements (2) (v cc = 1.8 to 4.0 v, v ss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter limits unit min. typ. max. t w (reset) reset input ?l? pulse width 2 s t c (x in ) main clock input cycle time (x in input) 2.0v v cc 4.0v 125 ns v cc < 2.0v 166 ns t wh (x in ) main clock input ?h? pulse width 2.0v v cc 4.0v 50 ns v cc < 2.0v 70 ns t wl (x in ) main clock input ?l? pulse width 2.0v v cc 4.0v 50 ns v cc < 2.0v 70 ns t c (cntr) cntr 0 , cntr 1 input cycle time 2.0v v cc 4.0v 1000/ v cc ns v cc < 2.0v 1000/(5 v cc-8) ns t wh (cntr) cntr 0 , cntr 1 input ?h? pulse width tc(cntr)/2-20 ns t wl (cntr) cntr 0 , cntr 1 input ?l? pulse width tc(cntr)/2-20 ns t wh (int) int 0 ? int 2 input ?h? pulse width 230 ns t wl (int) int 0 ? int 2 input ?l? pulse width 230 ns t c (s clk ) serial i/o1, 2 clock input cycle time (1) 2000 ns t wh (s clk ) serial i/o1, 2 clock input ?h? pulse width (1) 950 ns t wl (s clk ) serial i/o1, 2 clock input ?l? pulse width (1) 950 ns t su (r x d-s clk ) serial i/o1, 2 input setup time 400 ns th(s clk- r x d ) serial i/o1, 2 input hold time 200 ns qzrom version
rev.3.02 apr 10, 2008 page 103 of 131 rej03b0177-0302 38d2 group note: 1. the p5 5 /txd 1 [p3 2 /txd 2 ] p-channel output disable bit (bit 4 of address 001b 16 [001f 16 ]) of uart control register is ?0?. note: 1. the p5 5 /txd 1 [p3 2 /txd 2 ] p-channel output disable bit (bit 4 of address 001b 16 [001f 16 ]) of uart control register is ?0?. fig 94. circuit for measuring output switching characteristics table 32 switching characteristics (1) (vcc = 4.0 to 5.5 v, vss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter limits unit min. typ max. t wh (s clk ) serial i/o1, 2 clock output ?h? pulse width tc(s clk )/2-30 ns t wl (s clk ) serial i/o1, 2 clock output ?l? pulse width tc(s clk )/2-30 ns td(s clk -t x d) serial i/o1, 2 output delay time (1) 140 ns tv(s clk -t x d) serial i/o1, 2 output valid time (1) ? 30 ns tr(s clk ) serial i/o1, 2 clock output rising time 30 ns tf(s clk ) serial i/o1, 2 clock output falling time 30 ns table 33 switching characteristics (2) (v cc = 1.8 to 4.0 v, v ss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter limits unit min. typ max. t wh (s clk ) serial i/o1, 2 clock output ?h? pulse width tc(s clk )/2-80 ns t wl (s clk ) serial i/o1, 2 clock output ?l? pulse width tc(s clk )/2-80 ns td(s clk -t x d) serial i/o1, 2 output delay time (1) 350 ns tv(s clk -t x d) serial i/o1, 2 output valid time (1) -30 ns tr(s clk ) serial i/o1, 2 clock output rising time 80 ns tf(s clk ) serial i/o1, 2 clock output falling time 80 ns measurement output pin 100pf cmos output measurement output pin 100pf n-channel open-drain output (note) note: when bit 4 of the uart control register (address 001b 16 [address 0ff1 16 ]) is ?1.? (n-channel open-drain output mode) 1k qzrom version
rev.3.02 apr 10, 2008 page 104 of 131 rej03b0177-0302 38d2 group fig 95. timing diagram t c (cntr) t wl (cntr) t wh (cntr) 0.8v cc 0.2v cc cntr 0, cntr 1 int 0 ? int 2 reset t wl (int) t wh (int) 0.8v cc 0.2v cc 0.8v cc 0.2v cc t w (reset) t c (s clk ) t wl (s clk ) 0.8v cc 0.2v cc t wh (s clk ) t f t r t su (r x d-s clk )t h (s clk -r x d) t d (s clk -t x d) t v (s clk -t x d) 0.2v cc 0.8v cc s clk1 s clk2 r x d 1 r x d 2 t x d 1 t x d 2 x in t c (x in ) t wl (x in ) t wh (x in ) 0.8v cc 0.2v cc qzrom version
rev.3.02 apr 10, 2008 page 105 of 131 rej03b0177-0302 38d2 group flash memory version electrical characteristics absolute maximum ratings table 34 absolute maximum ratings symbol parameter conditions ratings unit v cc power source voltage all voltages are based on v ss . when an input voltage is measured, output transistors are cut off. ? 0.3 to 6.5 v v i input voltage p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 , p3 0 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 ? 0.3 to v cc + 0.3 v v i input voltage v l1 ? 0.3 to v l2 v v i input voltage v l2 v l1 to v l3 v v i input voltage v l3 v l2 to 6.5 v v i input voltage reset , x in , cnv ss ? 0.3 to v cc + 0.3 v v o output voltage p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 at output port ? 0.3 to v cc + 0.3 v at segment output ? 0.3 to v l3 + 0.3 v v o output voltage com 0 ? com 3 ? 0.3 to v l3 + 0.3 v v o output voltage p3 0 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 ? 0.3 to v cc + 0.3 v v o output voltage x out ? 0.3 to v cc + 0.3 v pd power dissipation ta=25 c 300 mw topr operating temperature ?? 20 to 85 c tstg storage temperature - ? 40 to 125 c flash memory version
rev.3.02 apr 10, 2008 page 106 of 131 rej03b0177-0302 38d2 group recommended operating conditions notes: 1. when the a/d converter is used, refer to the recommended operating conditions of the a/d converter. 2. 12.5 mhz < f(x in ) 16 mhz is not available in the frequency/2 mode. table 35 recommended operating conditions (1) (v cc = 2.7 to 5.5 v, v ss = 0 v, t a = ? 20 to 85 c unless otherwise noted) symbol parameter limits unit min. typ. max. v cc power source voltage (1) frequency/2 mode (2) f(x in ) 12.5mhz 4.5 5.5 v f(x in ) 8mhz 4.0 5.5 v f(x in ) 4mhz 2.7 5.5 v frequency/4 mode f(x in ) 16mhz 4.5 5.5 v f(x in ) 8mhz 2.7 5.5 v frequency/8 mode f(x in ) 16mhz 4.5 5.5 v f(x in ) 8mhz 2.7 5.5 v low-speed mode 2.7 5.5 v on-chip oscillator mode 2.7 5.5 v v ss power source voltage 0v v l3 lcd power source voltage 2.5 5.5 v v ref a/d converter reference voltage 2.7 v cc v av ss analog power source voltage 0 v v ia analog input voltage an 0 ? an 7 av ss v cc v v ih ?h? input voltage p0 4 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 , p3 0 , p3 2 , p3 5 , p3 6 , p4 0 ? p4 7 , p5 2 , p5 3 , p6 2 0.7v cc v cc v v ih ?h? input voltage p0 0 ? p0 3 , p3 1 , p3 3 , p3 4 , p3 7 , p5 0 , p5 1 , p5 4 ? p5 7 , p6 0 , p6 1 0.8v cc v cc v v ih ?h? input voltage reset 0.8v cc v cc v v ih ?h? input voltage x in 0.8v cc v cc v v il ?l? input voltage p0 4 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 , p3 0 , p3 2 , p3 5 , p3 6 , p4 0 ? p4 7 , p5 2 , p5 3 , p6 2 00.3v cc v v il ?l? input voltage p0 0 ? p0 3 , p3 1 , p3 3 , p3 4 , p3 7 , p5 0 , p5 1 , p5 4 ? p5 7 , p6 0 , p6 1 , cnv ss 00.2v cc v v il ?l? input voltage reset 00.2v cc v v il ?l? input voltage x in 00.2v cc v flash memory version
rev.3.02 apr 10, 2008 page 107 of 131 rej03b0177-0302 38d2 group notes: 1. the total output current is the sum of all the currents fl owing through all the applicable ports. the total average current i s an average value measured over 100 ms. the total peak current is the peak value of all the currents. 2. the peak output current is the peak current flowing in each port. 3. the average output current is average value measured over 100 ms. table 36 recommended operating conditions (3) (v cc = 2.7 to 5.5 v, v ss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter limits unit min. typ. max. i oh(peak) ?h? total peak output current (1) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 , p3 0 ? p3 7 ? 40 ma i oh(peak) ?h? total peak output current (1) p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 ? 40 ma i ol(peak) ?l? total peak output current (1) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 40 ma i ol(peak) ?l? total peak output current (1) p4 0 ? p4 7 , p5 0 , p5 1 , p5 4 ? p5 7 , p6 0 ? p6 2 40 ma i ol(peak) ?l? total peak output current (1) p3 0 ? p3 7 , p5 2 , p5 3 110 ma i oh(avg) ?h? total average output current (1) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 , p3 0 ? p3 7 ? 20 ma i oh(avg) ?h? total average output current (1) p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 ? 20 ma i ol(avg) ?l? total average output current (1) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 20 ma i ol(avg) ?l? total average output current (1) p4 0 ? p4 7 , p5 0 , p5 1 , p5 4 ? p5 7 , p6 0 ? p6 1 20 ma i ol(avg) ?l? total average output current (1) p3 0 ? p3 7 , p5 2 , p5 3 90 ma i oh(peak) ?h? peak output current (2) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 ? 2.0 ma i oh(peak) ?h? peak output current (2) p3 0 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 2 ? p6 2 ? 5.0 ma i ol(peak) ?l? peak output current (2) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 5.0 ma i ol(peak) ?l? peak output current (2) p4 0 ? p4 7 , p5 0 , p5 1 , p5 4 ? p5 7 , p6 0 ? p6 2 10 ma i ol(peak) ?l? peak output current (2) p3 0 ? p3 7 , p5 2 , p5 3 30 ma i oh(avg) ?h? average output current (3) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 ? 1.0 ma i oh(avg) ?h? average output current (3) p3 0 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 ? 2.5 ma i ol(avg) ?l? average output current (3) p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 2.5 ma i ol(avg) ?l? average output current (3) p4 0 ? p4 7 , p5 0 , p5 1 , p5 4 ? p5 7 , p6 0 ? p6 2 5.0 ma i ol(avg) ?l? average output current (3) p3 0 ? p3 7 , p5 2 , p5 3 15 ma flash memory version
rev.3.02 apr 10, 2008 page 108 of 131 rej03b0177-0302 38d2 group notes: 1. relationship between system clock frequency and power source voltage is shown in the graph below. 2. when the a/d converter is used, refer to the recommended operating conditions of the a/d converter. 3. 12.5 mhz < f(x in ) 16 mhz is not available in the frequency/2 mode. 4. the oscillation start voltage and the oscillation start time di ffer depending on factors such as the oscillator, circuit cons tants, and operating temperature range. note that oscillation start may be pa rticularly difficult at low voltage when using a high-frequen cy oscillator. 5. when using the microcomputer in low-speed mode, set t he clock input oscillation frequency on condition that f(x cin ) < f(x in )/3.
table 37 recommended operating conditions (4) (v cc = 2.7 to 5.5 v, v ss = 0 v, t a = ? 20 to 85 c, unless otherwise noted) symbol parameter conditions limits unit min. typ. max. f(cntr 0 ) f(cntr 1 ) timer x and timer y input frequency (duty cycle 50%) 4.5v v cc 5.5v 6.25 mhz 4.0v v cc < 4.5v 2 vcc ? 4mhz 2.7v v cc < 4.0v vcc mhz f(tclk) timer x, timer y, timer 1, timer 2, timer 3, timer 4 clock input frequency (count source frequency of each timer) 4.5v v cc 5.5v 16 mhz 4.0v v cc < 4.5v 4 vcc ? 8mhz 2.7v v cc < 4.0v 2 vcc mhz f( ) system clock frequency (1) 4.5v v cc 5.5v 6.25 mhz 4.0v v cc < 4.5v 4 mhz 2.7v v cc < 4.0v vcc mhz f(x in ) main clock input frequency (duty cycle 50%) (2)(3) 4.5v v cc 5.5v 1.0 16 mhz 2.7v v cc < 4.5v 1.0 8.0 mhz f(x cin ) sub-clock oscillation frequency (duty cycle 50%) (4)(5) 32.768 80 khz 4.0 4.5 5.5 2.7 4.0 6.25 [mhz] [v] system clock frequency power source voltage 0 2.7 2.7 4.5 5.5 8.0 [mhz] [v] main clock xin frequency power source voltage 0 1.0 16 flash memory version
rev.3.02 apr 10, 2008 page 109 of 131 rej03b0177-0302 38d2 group electrical characteristics note: 1. when the port xc switch bit (bit 4 of address 003b 16 ) of cpu mode register is ?1?, the drivability of p6 2 is different from the above. table 38 electrical characteristics (1) (v cc = 2.7 to 5.5 v, v ss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter test conditions limits unit min. typ. max. v oh ?h? output voltage p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 i oh = ? 2.5ma v cc ? 2.0 v v oh ?h? output voltage p3 0 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 (1) i oh = ? 5ma v cc ? 2.0 v i oh = ? 1.25ma v cc ? 0.5 v v ol ?l? output voltage p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 i ol =5ma 2.0 v i ol =1.25ma 0.5 v ol ?l? output voltage p4 0 ? p4 7 , p5 0 , p5 1 , p5 4 ? p5 7 , p6 0 ? p6 2 (1) i ol =10ma 2.0 v i ol =2.5ma 0.5 v ol ?l? output voltage p3 0 ? p3 7 , p5 2 , p5 3 i ol =15ma 2.0 v v t + ? v t ? hysteresis cntr 0 , cntr 1 , int 0 ? int 2 , kw 0 ? kw 7 0.5 v v t+ ? v t ? hysteresis rxd 1 , rxd 2 , s clk1 , s clk2 0.5 v v t+ ? v t ? hysteresis reset 0.5 v i ih ?h? input current p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 v i =v cc 5.0 a i ih ?h? input current p3 0 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 2 v i =v cc 5.0 a i ih ?h? input current reset , cnv ss v i =v cc 5.0 a i ih ?h? input current x in v i =v cc 4.0 a i il ?l? input current p0 0 ? p0 7 , p1 0 ? p1 7 , p2 0 ? p2 7 v i =v ss pull-up ?off? ? 5.0 a v cc =5.0v, v i =v ss pull-up ?on? ? 60 ? 120 ? 240 a v cc =3.0v, v i =v ss pull-up ?on? ? 25 ? 50 ? 100 a i il ?l? input current p3 0 ? p3 7 , p4 0 ? p4 7 , p5 0 ? p5 7 , p6 0 ? p6 7 v i =v ss pull-up ?off? ? 5.0 a v cc =5.0v, v i =v ss pull-up ?on? ? 30 ? 70 ? 140 a v cc =3.0v, v i =v ss pull-up ?on? ? 6.5 ? 25 ? 45 a i il ?l? input current reset , cnv ss v i =v ss ? 5.0 a i il ?l? input current x in v i =v ss ? 4.0 a f(oco) on-chip oscillator frequency v cc =5v, ta=25 c 2500 5000 7500 khz flash memory version
rev.3.02 apr 10, 2008 page 110 of 131 rej03b0177-0302 38d2 group a/d converter characteristics note: 1. confirm the recommended operating condition for main clock input frequency. table 39 electrical characteristics (2) (vcc = 2.7 to 5.5 v, v ss = 0 v, ta = ? 20 to 85 c, f(x cin ) = 32.768 khz, output transistors in the cut-off state, a/d converter stopped, unless otherwise noted) symbol parameter test conditions limits unit min. typ. max. v ram ram hold voltage when clock is stopped 2.2 5.5 v i cc power source current frequency/2 mode vcc=5.0v f(x in )=12.5mhz 4.0 7.0 ma f(x in )=12.5mhz (in wit state) 2.0 3.5 ma f(x in )=4mhz 2.0 3.5 ma vcc=2.7v f(x in )=4mhz 1.5 3 ma f(x in )=4mhz (in wit state) 1.0 2.5 ma f(x in )=2mhz 1.0 2.5 ma frequency/4 mode vcc=5.0v f(x in )=12.5mhz 3.2 5.6 ma f(x in )=12.5mhz (in wit state) 1.6 3.2 ma f(x in )=4mhz 1.6 3.2 ma vcc=2.7v f(x in )=8mhz 1.6 3.2 ma f(x in )=8mhz (in wit state) 1.0 2.5 ma f(x in )=4mhz 1.0 2.5 ma frequency/8 mode vcc=5.0v f(x in )=12.5mhz 2.5 5 ma f(x in )=12.5mhz (in wit state) 1.5 3 ma f(x in )=4mhz 1.5 3 ma vcc=2.7v f(x in )=8mhz 1.5 3 ma f(x in )=8mhz (in wit state) 1.0 2.5 ma f(x in )=4mhz 1.0 2.5 ma low-speed mode vcc=5.0v f(x in )=stop 400 800 a in wit state ta = 2 5 c 4.0 10 a ta = 8 5 c20 vcc=2.7v f(x in )=stop 300 600 a in wit state ta=25 c3.79 a ta = 8 5 c18 on-chip oscillator mode f(x in ), f(x cin ): stop vcc=5.0v 600 1200 a vcc=2.7v 500 1000 a vcc=2.7v (in wit state) 500 1000 a all oscillations are stopped (in stp state) ta = 2 5 c0.63.0 a ta = 8 5 c1.0 a current increased at a/d converter operating f(x in )=12.5mhz, v cc =5v in frequency/2, 4 or 8 mode 1.0 ma f(x in )=stop, v cc =5v in on-chip oscillator operating 1.0 ma f(x in )=stop, v cc =5v in low-speed mode 0.8 ma table 40 a/d converter recommended operating condition (vcc = 2.7 to 5.5 v, ta = ? 20 to 85 c, output transistors in cut-off state, unless otherwise noted) symbol parameter test conditions limits unit min. typ. max. v cc power source voltage 2.7 5.0 5.5 v v ih ?h? input voltage adkey 0.9v cc v cc v v il ?l? input voltage adkey 00.7 v cc ? 0.5 v f( ad ) ad converter clock frequency (1) (low-speed ? on-chip oscillator mode excluded) 4.5v < v cc 5.5v 6.25 mhz 4.0v < v cc 4.5v 4.0 mhz 2.7v < v cc 4.0v v cc mhz flash memory version
rev.3.02 apr 10, 2008 page 111 of 131 rej03b0177-0302 38d2 group notes: 1. tc( ad): one cycle of ad conversion clock. ad conversion clock can be selected from source/2 or source/8. source represents the x in input in the frequency/2, 4 or 8 mode and internal on-chip os cillator divided by 4 in the on-chip oscillator mode or the low-speed mode. when the a/d conversion is executed in the frequency/2 mode, frequency/4 mode, or frequency/8 mode, set f(x in ) 500 khz. relationship among ad conversion clock frequency, power source voltage, ad conversion mode and absolute accuracy. table 41 a/d converter characteristics (vcc = 2.7 to 5.5 v, ta = ? 20 to 85 c, output transistors in cut-off state, low-speed ? on-chip oscillator mode included, unless otherwise noted) symbol parameter test conditions limits unit min. typ. max. ? resolution 10 bits abs absolute accuracy (quantification error excluded) 10bitad mode 4.5v < v cc 5.5v, ad conversion clock =f(x in )/2, f(x in )/8 6.25mhz 4lsb 4.0v < v cc 4.5v, ad conversion clock =f(x in )/2, f(x in )/8 4mhz 2.7v v cc 4.0v, ad conversion clock =f(x in )/2, f(x in )/8 vccmhz 2.7v v cc 5.5v, f(oco)/8, f(oco)/32 8bitad mode 4.5v < v cc 5.5v, ad conversion clock =f(x in )/2, f(x in )/8 6.25mhz 2 4.0v < v cc 4.5v, ad conversion clock =f(x in )/2, f(x in )/8 4mhz 2.7v v cc 4.0v, ad conversion clock =f(x in )/2, f(x in )/8 vccmhz 2.7v v cc 5.5v, f(oco)/8, f(oco)/32 t conv conversion time (1) 10bitad mode tc( ad) 61 tc( ad) 62 s 8bitad mode tc( ad) 49 tc( ad) 50 r ladder ladder resistor 12 35 100 k i vref reference input current v ref =5v 50 150 200 a i ia analog input current 5.0 a 4.0 4.5 5.5 4.0 6.25 [mhz] [v] ad conversion clock frequency power source voltage vcc note : f(x in ) 500khz 2.7 2.7 10bitad=4lsb 8bitad=2lsb ad conversion clock ? frequency/2 mode, frequency/4 and frequency/8 mode: f(x in )/2 or f(x in )/8 0 (note) ad conversion clock ? low-speed mode and on-chip oscillator mode: f(oco)/8 or f(oco)/32 f(x in )/2 or f(x in )/8 10bitad=4lsb 8bitad=2lsb flash memory version
rev.3.02 apr 10, 2008 page 112 of 131 rej03b0177-0302 38d2 group lcd power supply characteristics note: 1. the value is the average of each one division resistor. table 42 lcd power supply characteristics ( when connecting division resistors for lcd power supply ) (v cc = 2.7 to 5.5 v, v ss = 0 v, ta = ?20 to 85c, unless otherwise noted) symbol parameter test conditions limits unit min. typ. max. r lcd division resister for lcd power supply (1) rsel=?10? 200 k rsel=?11? 5 lcd drive timing a lcd circuit division ratio = divided by 1 rsel=?01? 120 rsel=?00? 90 lcd circuit division ratio = divided by 2 rsel=?01? 150 rsel=?00? 120 lcd circuit division ratio = divided by 4 rsel=?01? 170 rsel=?00? 150 lcd circuit division ratio = divided by 8 rsel=?01? 190 rsel=?00? 170 lcd drive timing b lcd circuit division ratio = divided by 1 rsel=?01? 150 rsel=?00? 120 lcd circuit division ratio = divided by 2 rsel=?01? 170 rsel=?00? 150 lcd circuit division ratio = divided by 4 rsel=?01? 190 rsel=?00? 170 lcd circuit division ratio = divided by 8 rsel=?01? 190 rsel=?00? 190 flash memory version
rev.3.02 apr 10, 2008 page 113 of 131 rej03b0177-0302 38d2 group timing requirements and switching characteristics notes: 1. 80 ns in the frequency/2 mode. 2. 32 ns in the frequency/2 mode. 3. when bit 6 of address 001a 16 , 001f 16 are ?1? (clock synchronous). divide this value by four when bit 6 of address 001a 16 , 001f 16 are ?0? (uart). note: 1. when bit 6 of address 001a 16 , 001f 16 are ?1? (clock synchronous). divide this value by four when bit 6 of address 001a 16 , 001f 16 are ?0? (uart). table 43 power supply circuit characteristics (vcc = 2.7 to 5.5 v, vss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter test conditions limits unit min. typ. max. td(p-r) internal power source voltage stabilizes time at power-on 2.7 v cc 5.5v 2 ms table 44 timing requirements (1) (vcc = 4.0 to 5.5 v, vss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter limits unit min. typ. max. t w (reset) reset input ?l? pulse width 2 s t c (x in ) main clock input cycle time 4.5v v cc 5.5v (1) 62.5 ns 4.0v v cc < 4.5v 125 ns t wh (x in ) main clock input ?h? pulse width 4.5v v cc 5.5v (2) 25 ns 4.0v v cc < 4.5v 50 ns t wl (x in ) main clock input ?l? pulse width 4.5v v cc 5.5v (2) 25 ns 4.0v v cc < 4.5v 50 ns t c (cntr) cntr 0 , cntr 1 input cycle time 250 ns t wh (cntr) cntr 0 , cntr 1 input ?h? pulse width 105 ns t wl (cntr) cntr 0 , cntr 1 input ?l? pulse width 105 ns t wh (int) int 0 ? int 2 input ?h? pulse width 80 ns t wl (int) int 0 ? int 2 input ?l? pulse width 80 ns t c (s clk ) serial i/o1, 2 clock input cycle time (3) 800 ns t wh (s clk ) serial i/o1, 2 clock input ?h? pulse width (3) 370 ns t wl (s clk ) serial i/o1, 2 clock input ?l? pulse width (3) 370 ns t su (r x d-s clk ) serial i/o1, 2 input setup time 220 ns t h (s clk -r x d) serial i/o1, 2 input hold time 100 ns table 45 timing requirements (2) (v cc = 2.7 to 4.0 v, v ss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter limits unit min. typ. max. t w (reset) reset input ?l? pulse width 2 s t c (x in ) main clock input cycle time (x in input) 125 ns t wh (x in ) main clock input ?h? pulse width 50 ns t wl (x in ) main clock input ?l? pulse width 50 ns t c (cntr) cntr 0 , cntr 1 input cycle time 1000/v cc ns t wh (cntr) cntr 0 , cntr 1 input ?h? pulse width tc(cntr)/2 ? 20 ns t wl (cntr) cntr 0 , cntr 1 input ?l? pulse width tc(cntr)/2 ? 20 ns t wh (int) int 0 ? int 2 input ?h? pulse width 230 ns t wl (int) int 0 ? int 2 input ?l? pulse width 230 ns t c (s clk ) serial i/o1, 2 clock input cycle time 2000 ns t wh (s clk ) serial i/o1, 2 clock input ?h? pulse width 950 ns t wl (s clk ) serial i/o1, 2 clock input ?l? pulse width 950 ns t su (r x d-s clk ) serial i/o1, 2 input setup time 400 ns t h (s clk -r x d) serial i/o1, 2 input hold time 200 ns flash memory version
rev.3.02 apr 10, 2008 page 114 of 131 rej03b0177-0302 38d2 group note: 1. the p5 5 /txd 1 [p3 2 /txd 2 ] p-channel output disable bit (bit 4 of address 001b 16 [0ff1 16 ]) of uart control register is ?0?. note: 1. the p5 5 /txd 1 [p3 2 /txd 2 ] p-channel output disable bit (bit 4 of address 001b 16 [0ff1 16 ]) of uart control register is ?0?. fig 96. circuit for measuring output switching characteristics table 46 switching characteristics (1) (vcc = 4.0 to 5.5 v, vss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter limits unit min. typ max. t wh (s clk ) serial i/o1, 2 clock output ?h? pulse width t c (s clk )/2 ? 30 ns t wl (s clk ) serial i/o1, 2 clock output ?l? pulse width t c (s clk )/2 ? 30 ns t d (s clk -t x d) serial i/o1, 2 output delay time (1) 140 ns t v (s clk -t x d) serial i/o1, 2 output valid time (1) ? 30 ns t r (s clk ) serial i/o1, 2 clock output rising time 30 ns t f (s clk ) serial i/o1, 2 clock output falling time 30 ns table 47 switching characteristics (2) (v cc = 2.7 to 4.0 v, v ss = 0 v, ta = ? 20 to 85 c, unless otherwise noted) symbol parameter limits unit min. typ max. t wh (s clk ) serial i/o1, 2 clock output ?h? pulse width t c (s clk )/2 ? 80 ns t wl (s clk ) serial i/o1, 2 clock output ?l? pulse width t c (s clk )/2 ? 80 ns t d (s clk -t x d) serial i/o1, 2 output delay time (1) 350 ns t v (s clk -t x d) serial i/o1, 2 output valid time (1) ? 30 ns t r (s clk ) serial i/o1, 2 clock output rising time 80 ns t f (s clk ) serial i/o1, 2 clock output falling time 80 ns measurement output pin 100pf cmos output measurement output pin 100pf n-channel open-drain output (note) 1k note: when bit 4 of the uart control register (address 001b16 [address 0ff116]) is ?1.? (n-channel open-drain output mode) flash memory version
rev.3.02 apr 10, 2008 page 115 of 131 rej03b0177-0302 38d2 group fig 97. timing diagram (in single-chip mode) int 0 ? int 2 cntr 0 , cntr 1 0.2v cc t wl (int) 0.8v cc t wh (int) 0.2v cc 0.2v cc 0.8v cc 0.8v cc 0.2v cc t wl (x in ) 0.8v cc t wh (x in ) t c (x in ) x in 0.2v cc 0.8v cc t w (reset) t f t r 0.2v cc t wl (cntr) 0.8v cc t wh (cntr) t c (cntr) t d (s clk -t x d) t v (s clk -t x d) t c (s clk ) t wl (s clk )t wh (s clk ) t h (s clk -r x d) t su (r x d-s clk ) t x d 1 t x d 2 r x d 1 r x d 2 s clk1 s clk2 reset flash memory version
rev.3.02 apr 10, 2008 page 116 of 131 rej03b0177-0302 38d2 group package outline diagrams showing the latest package dimensions and mounting info rmation are available in the ?packages? section of the renesas technology website. terminal cross section b1 c1 bp c 2. 1. dimensions " * 1" and " * 2" do not include mold flash. note) dimension " * 3" does not include trim offset. * 3 116 17 32 33 48 49 64 f * 1 * 2 x y index mark d h d e h e e b p z d z e detail f c a a 2 a 1 l l 1 previous code jeita package code renesas code plqp0064ga-a 64p6u-a mass[typ.] 0.7g p-lqfp64-14x14-0.80 1.0 0.125 0.35 1.0 1.0 0.20 0.20 0.145 0.09 0.42 0.37 0.32 max nom min dimension in millimeters symbol reference 14.1 14.0 13.9 d 14.1 14.0 13.9 e 1.4 a 2 16.2 16.0 15.8 16.2 16.0 15.8 1.7 a 0.2 0.1 0 0.7 0.5 0.3 l x 8 0 c 0.8 e 0.10 y h d h e a 1 b p b 1 c 1 z d z e l 1
rev.3.02 apr 10, 2008 page 117 of 131 rej03b0177-0302 38d2 group terminal cross section b 1 c 1 b p c 2. 1. dimensions " * 1" and " * 2" do not include mold flash. note) dimension " * 3" does not include trim offset. index mark * 3 17 32 64 49 116 33 48 f * 1 * 2 x y b p h e e h d d z d z e detail f a c a 2 a 1 l 1 l p-lqfp64-10x10-0.50 0.3g mass[typ.] 64p6q-a / fp-64k / fp-64kv plqp0064kb-a renesas code jeita package code previous code 1.0 0.125 0.18 1.25 1.25 0.08 0.20 0.145 0.09 0.25 0.20 0.15 max nom min dimension in millimeters symbol reference 10.1 10.0 9.9 d 10.1 10.0 9.9 e 1.4 a 2 12.2 12.0 11.8 12.2 12.0 11.8 1.7 a 0.15 0.1 0.05 0.65 0.5 0.35 l x 8 0 c 0.5 e 0.08 y h d h e a 1 b p b 1 c 1 z d z e l 1 e
rev.3.02 apr 10, 2008 page 118 of 131 rej03b0177-0302 38d2 group appendix note on programming 1. processor status register (1) initialization of the pr ocessor status register it is required to initialize the pr ocessor status register (ps) flags which affect program execution. it is par ticularly essential to initialize the t and d flags because of their effect on calculations. initialize these flags at the beginning of the program. at a reset, the contents of the pr ocessor status register (ps) are undefined except for the i flag which is ?1?. fig. 98 initialization of processor status register flags (2) how to refer the processor status register to refer the contents of the processor status register (ps), execute the php instruction once and then read the contents of (s+1). if necessary, execute the plp instruction to return the stored ps to its original status. fig. 99 stack memory cont ents after php instruction execution 2. decimal calculations (1) instructions for decimal calculations to perform decimal ca lculations, set the de cimal mode (d) flag to ?1? with the sed instruction and execute the adc or sbc instruction. in that case, after the adc or sbc instruction, execute another instruction be fore the sec, clc, or cld instruction. fig. 100 instructions for decimal calculations (2) status flag at decimal calculations when the adc or sbc instructio n is executed in decimal mode (d flag = ?1?), three of the status flags (n, v, and z) are disabled. the carry (c) flag is set to ?1? if a carry is generated and is cleared to ?0? if a borrow is gene rated as a result of a calculation, so it can be used to determine whether the calculation has generated a carry or borrow. initialize the c flag before each calculation. reset initialize the flags main program stored ps (s) (s) + 1 set the decimal mode (d) flag to ?1? execute the adc or sbc instruction nop execute the sec, clc, or cld instruction
rev.3.02 apr 10, 2008 page 119 of 131 rej03b0177-0302 38d2 group 3. jmp instruction when using the jmp instruction (indirect addressing mode), do not specify the address where ?ff 16 ? is allocated to the low- order 8 bits as the operand. 4. multiplication and division instructions (1) the mul and div instructions are not affected by the t and d flags. (2) executing these instructions does not change the contents of the processor status register. 5. read-modify-write instruction do not execute any read-modify-w rite instruction to the read invalid (address) sfr. the read-modify-write instructio n reads 1-byte of data from memory, modifies the data, and wr ites 1-byte the data to the original memory. in the 740 family, the read-modify -write instructions are the following: (1) bit handling instructions: clb, seb (2) shift and rotate instructions: asl, lsr, rol, ror, rrf (3) add and subtract instructions: dec, inc (4) logical operation instruct ions (1?s complement): com although not the read-modify-wr ite instructions, add and subtract/logical oper ation instructions (adc, sbc, and, eor, and ora) when t flag = ?1? operate in the way as the read- modify-write instruction. do not execute them to the read invalid sfr. when the read-modify-write inst ruction is execu ted to the read invalid sfr, the following may result: as reading is invalid, the read value is undefined. the instruction modifies this undefined value an d writes it back, so the written value will be indeterminate. notes on peripheral functions notes on i/o ports 1. use in stand-by state when using the mcu in stand-by state* 1 for low-power consumption, do not leave th e input level of an i/o port undefined. be especially careful to the i/o ports for the n- channel open-drain. in this case, pull-up (connect to vcc) or pull-down (connect to vss) these ports through a resistor. when determining a resistance value, note the following: ? external circuit ? variation in the output level during ordinary operation when using a built-in pull-up resistor, note variations in current values: ? when setting as an input port: fix the input level ? when setting as an output port: prevent current from flowing out externally. even if a port is set to output by the direction register, when the content of the port latc h is ?1?, the transistor becomes the off state, which allows the port to be in the high-impedance state. this may cause the level to be undefined depending on external circuits. as described above, if the input level of an i/o port is left undefined, the power source cu rrent may flow because the potential applied to the input buffe r in the mcu will be unstable. * 1 stand-by state: stop mode by ex ecuting the stp instruction wait mode by executing the wit instruction 2. modifying output data with bit handling instruction when the port latch of an i/o port is modified with the bit handling instruction* 1 , the value of an unspecified bit may change. i/o ports can be set to input mode or output mode in byte units. when the port register is read or written, the following will be operated: ? port as input mode read: read the pin level write: write to the port latch ? port as output mode read: read the port latch or peripheral function output (specifications vary depending on the port) write: write to the port latch (output the content of the port latch from the pin) meanwhile, the bit handling inst ructions are the read-modify- write instructions* 2 . executing the bit handling instruction to the port register allows reading and writing a bit unspecified with the instruction at the same time. if an unspecified bit is set to input mode, the pin level is read and the value is written to the port la tch. at this time, if the original content of the port latch and the pin level do not match, the content of the port latch changes. if an unspecified bit is set to output mode, the port latch is normally read, but the peripheral function output is read in some ports and the value is written to the port latch. at this time, if the original content of the port latch and the peripheral function output do not match, the content of the port latch changes. *1 bit handling instru ctions: clb, seb *2 read-modify-write instructi on: reads 1-byte of data from memory, modifies the data, and writes 1-byte of the data to the original memory.
rev.3.02 apr 10, 2008 page 120 of 131 rej03b0177-0302 38d2 group 3. direction registers the values of the port direction registers cannot be read. this means, it is impossible to use the lda instruction, memory operation instruction when the t flag is ?1?, addressing mode using direction register values as qualifiers, and bit test instructions such as bbc and bbs. it is also impossible to use bit operation instructions such as clb and seb, and read-modify- write instructions to direction registers, including calculations such as ror. to set the direction registers, use instructions such as ldm or sta. 4. pull-up control only for the pin set to input mode, pull-up is controlled by the pull register and the segm ent output disable register. notes on termination of unused pins 1. termination of unused pins perform the following at the shortest possible distance (20 mm or less) from the mcu pins. (1) i/o ports set the ports to input mode and connect each pin to v cc or v ss through a resistor of 1 k to 10 k . an internal pull- up resistor can also be used for the port where the internal pull-up resister is selectable. to set the ports to output mode, leave open at ?l? or ?h? output. ? when setting the ports to ou tput mode and leave open, input mode in the initial state remains until the mode of the ports are switched to output mode by a program after a reset. this may cause the voltage level of the pins to be undefined and the power sour ce current to increase while the ports remains in input mode. for any effects on the system, careful system evaluations should be implemented on the user side. ? the direction registers may be changed due to a program runaway or noise, so reset the registers periodically by a program to increase the program reliability. 2. termination concerns (1) when setting i/o ports to input mode [1] do not leave open ? the power source current may increase depending on the first-stage circuit. ? the ports are more likely affected by noise when compared with the termination shown on the above ?1. (1) i/o ports? [2] do not connect to v cc or v ss directly if the direction registers are ch anged to output mode due to a program runaway or noise, a short circuit may occur. [3] do not connect multiple ports in a lump to v cc or v ss through a resistor. if the direction registers are ch anged to output mode due to a program runaway or noise, a shor t circuit may occur between the ports.
rev.3.02 apr 10, 2008 page 121 of 131 rej03b0177-0302 38d2 group notes on interrupts 1. changing related register settings if the interrupt occurrence sy nchronized with the following settings is not re quired, take the se quence shown below. ? when selecting the external interrupt active edge ? when selecting the interrupt s ource of the interrupt vector address where two or more in terrupt sources are allocated fig. 101 sequence for setting related register in the following cases, the in terrupt request bit of the corresponding interrupt may be set to ?1?. ?int 0 interrupt edge selection bit (bit 0 of interrupt edge se lection register (address 003a 16 )) ?int 1 interrupt edge selection bit (bit 1 of interrupt edge selection register) ?int 2 interrupt edge selection bit (bit 2 of interrupt edge selection register) ?cntr 0 active edge switch bits (bits 6 and 7 of timer x c ontrol register 1 (address 002e 16 )) ?cntr 1 active edge switch bit (bits 6 of timer y mode register (address 0038 16 )) ? int2/key input in terrupt switch bit (bit 3 of interrupt edge selection register) ? timer y/cntr 1 interrupt switch bit (bit 4 of interrupt edge selection register) 2. checking interrupt request bit to check the interrupt request bit with the bbc or bbs instruction immediately after this bit is set to ?0?, take the following sequence. if the bbc or bbs instruction is executed immediately after the interrupt request bit is set to ?0?, the bit value before being set to ?0? is read. fig. 102 sequence for setting interrupt request bit 3. setting unus ed interrupts set the interrupt enable bit of the unused interrupt to ?0? (disabled). set the interrupt edge selection bit (active edge switch bit) or interrupt (source) selection bit. nop (one or more instructions) set the corresponding interrupt enable bit to ?0? (disabled). set the corresponding interrupt request bit to ?0? (no interrupt request). set the corresponding interrupt enable bit to ?1? (enabled). nop (one or more instructions) set the interrupt request bit to ?0? (no interrupt) execute the bbc or bbs instruction
rev.3.02 apr 10, 2008 page 122 of 131 rej03b0177-0302 38d2 group notes on timers 1. frequency divider all timers shares one circuit for the frequency divider to generate the count source. thus the frequency divider is not initialized when each individual timer is activated. when the frequency divider is selected as the count source, a one-cycle delay of the maximum count source will result between wh en the timer is activated and when it starts counting or outputs the waveform. the count source cannot be observed externally. 2. division ratio for timer 1 to 4 the division ratio is 1/(n+1) when the value n (0 to 255) is written to the timer latch. 3. switching frequency and count source for timer 1 to 4, x, and y switch the frequency division or count source* while the timer count is stopped. *this also applies when the frequency divider output is selected as the timer count source and th e count source is switched in conjunction with a transition between operating modes (on- chip oscillator mode, x in mode, or low-speed mode). be careful when changi ng settings in the cp u mode register. 4. setting timer 1 and 2 when stp instruction executed before executing the stp instruction, first set the wait time at return. 5. setting order to timer 1 to 4 when switching the count source of timer 1 to timer 4, a narrow pulse may be generated at the c ount input, which ca uses the timer count value to be undefined. also, if the timers are used in cascade connection, a narrow pul se may be generated at the output when writing to the pervi ous timer, which causes the next timer count value to be undefined. thus set the value from timer 1 in order after setting the count source of timer 1 to timer 4. 6. write to timer 2, 3, and 4 when writing to the latch only, if the write timing to the reload latch and the underflow timing ar e almost the same, the value is set into the timer and the timer latch at the same time. at this time, count is stopped dur ing write operation to the reload latch. 7. timer 3 pwm 0 mode, timer 4 pwm 1 mode (1) when pwm output is suspende d once it starts, the time to resume outputting may be delayed one section (256 ts) of the short interval depending on the level of the output pulse at that time: stop at ?h?: no output delay stop at ?l?: output is delayed time of 256 ts (2) when pwm mode is used, the interrupt requests and values of timer 3 and timer 4 are upda ted every cycle of the long interval (4 256 ts). 8. write order to timer x (1) when timer mode, pulse outpu t mode, event counter mode, or pulse width measurement m ode is set, write to the following registers in the order below: the timer x regi ster (extension) the timer x register (low-order) the timer x regist er (high-order) writing to only one of these registers cannot be performed. when either of the above modes is set and timer x operates as a 16-bit counter, if the timer x register (extension) is never set after a reset release, setting the timer x register (extension) is not required. in that case, write the timer x register (low-order) first and th e timer x register (high-order) next. however, once the timer x register (extension) is written, note that the value is retained in the reload latch. (2) write to the timer x register by the 16-bit unit. do not read the timer x register while write operation is performed. if the write operation is not complete d, normal operation will not be performed. (3) when igbt output mode or pwm mode is set, do not write ?1? to the timer x register (extension). if ?1? has been already written to the timer x register, be sure to write ?0? to the register before use. write to the following registers in the order below: the compare registers 1, 2, 3 (high- and low-order) the timer x regi ster (extension) the timer x register (low-order) the timer x regist er (high-order) the compare registers (high- and low-order) can be written in either order. however, be sure to write both the compare registers 1, 2, 3 and the timer x register at the same time. 9. read order to timer x (1) in all modes, read the follow ing registers in the order below: the timer x register (extension) the timer x register (high-order) the timer x register (low-order) when reading the timer x re gister (extension) is not required, read the timer x regist er (high-order) first and the timer x register (low-order) next. the read order to the compar e registers 1, 2, 3 is not specified. (2) read the timer x register in 16-bit units. do not write to it during read operation. if r ead operation is terminated in progress, normal operation will not be performed.
rev.3.02 apr 10, 2008 page 123 of 131 rej03b0177-0302 38d2 group 10. write to timer x (1) timer x can select either wr iting data to both the latch and the timer at the same time or writing data only by the timer x write control bit (b3) in the timer x mode register (address 002d 16 ). when writing to the latch only, if a value is written to the timer x address, the value is set into the reload latch and the timer is updated at the next underflow. after a reset release, if a value is written to the timer x address, the value is set into the timer and the timer latch at the same time, because they are written simultaneously. when writing to the latch only , if the write timing to the high-order reload latch and the underflow timing are almost the same, the value is set into the timer and the timer latch at the same time. at this time, co unt is stopped during write operation to the high-order reload latch. (2) switch the frequency divisi on or count source* while the timer count is stopped. *this also applies when the frequency divider output is selected as the timer count source and th e count source is switched in conjunction with a transition between operating modes (on- chip oscillator mode, x in mode, or low-speed mode). be careful when changi ng settings in the cp u mode register. 11. setting timer x mode register when pwm mode or igbt output mode is set, be sure to set the write control bit in the timer x m ode register to ?1? (writing to latch only). after writing to the t imer x register (high-order), the contents of both registers are simultaneously reflected in the output waveform at the next underflow. 12. timer x output control functions to use the output control functions (int 1 and int 2 ), set the levels of int 1 and int 2 to ?h? for the falling edge active or to ?l? for the rising edge active before switching to igbt output mode. 13. cntr 0 active edge selection (1) setting the cntr 0 active edge switch bits also affects the interrupt active edge at the same time. (2) when the pulse width is measured, set bit 7 of the cntr 0 active edge switch bits to ?0?. 14. when timer x pulse width measurement mode used when timer x pulse mode measurem ent mode is used, enable the event counter wind control data (bit 5 of timer x mode register (address 002d 16 )) by setting to ?0?. if the event counter window control data (bit 5 of timer x mode register (address 002d 16 )) is set to ?1? (disabled) to enable/disable the cntr 0 input, the input is not accepted after the timer 1 underflow. 15. cntr1 active edge selection setting the cntr 1 active edge switch bits also affects the interrupt active edge at the same time. however, in pulse width hl co ntinuous hl measurement mode, the cntr 1 interrupt request is generated at both rising and falling edges of the pin regardless of the settings of the cntr 1 active edge switch bits. 16. read from/write to timer y (1) when reading from/writing to timer y, read from/write to both the high-order and low-or der bytes of timer y. to read the value, read the high-order bytes first and the low-order bytes next. to write the value, write the low-order bytes first and the high-order bytes next. writing/reading sh ould be preformed in 16-bit units. if write/read operation is changed in progress, normal operation will not be performed. (2) timer y can select either writing data to both the latch and the timer at the same time or writing data only by the timer y write control bit (b0) in the timer y control register (address 0039 16 ). when writing to the latch only, if a value is written to the timer y addres s, the value is set into the reload latch and the timer is updated at the next underflow. after a reset release, if a value is written to the timer y address, the value is set into the timer and the timer latch at the same time, because they are written simultaneously. when writing to the latch only , if the write timing to the high-order reload latch and the underflow timing are almost the same, the value is set into the timer and the timer latch at the same time. at this time, co unt is stopped during write operation to the high-order reload latch. (3) switch the frequency divisi on or count source* while the timer count is stopped. *this also applies when the frequency divider output is selected as the timer count source and th e count source is switched in conjunction with a transition between operating modes (on- chip oscillator mode, x in mode, or low-speed mode). be careful when changing settings in the cpu mode register. 17. real time port control when switching the setting of the real time port control bits between valid and invalid, write to the timer y mode register in byte units with the ldm or sta in struction so that both bits are switched at the same time. also, before using this function, set the p4 6 and p4 7 port direction registers to output.
rev.3.02 apr 10, 2008 page 124 of 131 rej03b0177-0302 38d2 group notes on serial i/o1 becaouse the operation of the serial i/o2 is as same as serial i/o1, the following notes are written about the serial i/o1. 1. write to baud rate generator write to the baud rate generato r while transmis sion/reception is stopped. 2. setting sequence when serial i/o1 transmit interrupt used to use the serial i/o1 trans mit interrupt, if the interrupt occurrence synchronized with setti ngs is not required, take the following sequence: (1) set the serial i/o1 transmit interrupt enable bit (bit 2 of interrupt control register 2 (address 003f 16 )) to ?0? (disabled). (2) set the transmit enable bit to ?1?. (3) after one or more instructi ons have been executed, set the serial i/o1 transmit interrupt request bit (bit 2 of interrupt request register 2 (address 003d 16 )) to ?0? (no interrupt). (4) set the serial i/o1 transmit interrupt enable bit to ?1? (enabled). when the transmit enable bit is set to ?1?, the transmit buffer empty flag (bit 0 of serial i/o1 status register) and the transmit shift completion flag are set to ?1?. this allows an interrupt reques t to be generated regardless of which interrupt occurrence sour ce has been selected by the transmit interrupt source selection bit (bit 3 of serial i/o1 control register) and the serial i/o1 transmit interrupt request bit is set to ?1?. 3. data transmission control using transmit shift completion flag after transmit data is written to the transmit buffer register, the transmit shift completion flag (bit 2 of serial i/o1 status register (address 0019 16 )) changes from ?1? to ?0? after a delay of 0.5 to 1.5 cycles of the system clock. t hus, after transmit data is written to the transmit buffer register, note this delay when controlling data transmission by referenc ing the transmit shift completion flag. 4. setting serial i/o1 control register before setting the serial i/o1 cont rol register again, first set both the transmit enable bit and the receive enable bit to ?0? and initialize the transmission and reception circuits. fig. 103 sequence of setting serial i/o1 control register 5. pin status after transmission completed after transmission is completed, the txd pin retains the level when transmission is completed. when the internal clock is sel ected in clock synchronous serial i/o mode, the s clk1 pin is set to ?h?. 6. serial i/o1 enable bit during transmit operation during transmission, if the serial i/o1 enable bit (bit 7 of serial i/o1 control register (address 001a 16 )) is set to ?0?, the pin function is set to an i/o port and the internal transmit operation continues even though transmit data is not output externally. also, if the transmit buffer register is written in this state, transmit operation starts internally. if the serial i/o1 enable bit is set to ?1? at this time, transmit data is output to the txd pin from that point. 7. transmission control when external clock selected during data transmission , if the external clock is selected as the synchronous clock, set the transmit enable bit to ?1? while s clk1 is set to ?h?. also, write to th e transmit buffer register while s clk1 is set to ?h?. 8. receive operation in clock synchronous serial i/o mode during reception in clock synchronous serial i/o mode, set both the transmit enable bit and the receive enable bit to ?1?. then write dummy data to the transmit buffer register. when the internal clock is selected as the synchronous clock, the synchronous clock is output at this point and receive operation starts. when the external clock is selected, reception is enabled at this point and inputting the ex ternal clock starts transmit operation. the p5 5 /t x d 1 [p3 2 /txd 2 ] pin outputs dummy data written in the transmit buffer register. 9. transmit/receive operation in clock synchronous serial i/o mode in clock synchronous serial i/o m ode, set the transmit enable bit and the receive enable bit to ?0? simultaneously to stop transmit/receive operations. if on ly one of the operations is stopped, transmission and recep tion cannot be synchronized, which will cause a bit error. set bits 0 to 3, and 6 of the serial i/o1 control register. set both the transmit enable bit (te) and the receive enable bit (re) to ?0? set both the transmit enable bit (te) and the receive enable bit (re), or one of them to ?1?. settings can be made with the ldm instruction at the same time
rev.3.02 apr 10, 2008 page 125 of 131 rej03b0177-0302 38d2 group notes on a/d conversion 1. analog input pin set the signal source impedance fo r analog input low, or equip an analog input pin with an external capacitor of 0.01 f to 1 f. in addition, operations of app lication products s hould be verified thoroughly on the user side. an analog input pin has a built-in capacitor for analog voltage comparison. thus if a signal from the high impedance signal source is input to the analog input pin, charge and discharge noise will be generated. this may cause the a/d conversion/comparison accuracy to drop. 2. clock frequency during a/d conversion the comparator input consists of a capacity coupling. if the conversion rate is too low, the a/d conversion accuracy may deteriorate due to a charge lost, so set f(x in ) 500 khz or more for a/d conversion in x in mode. also, do not execute the stp or wit instruction duri ng a/d conversion. in low-speed mode (when on-chip os cillator is selected), as a/d conversion is performed using th e internal on-chip oscillator, there is no limit on the minimum frequency for f(x in ). 3. adkey function when the adkey enable bit is set to ?1?, the analog input pin selection bits are di sabled. do not execute the a/d conversion by a program while adkey is en abled. enabling adkey does not change bits 0 to 2 of adcon. 4. a/d conversion immediately after adkey function started in the adkey function, a/d conve rsion is not performed to the analog input voltage immediately after starting the function. this causes the a/d conversion resu lt immediately after starting the function to be undefined. if the a/d conversion result of the analog input voltage applied to the adkey pin is required, select the analog input pin correspondi ng to adkey before performing a/d conversion. 5. input voltage applied to adkey pin set the input to the adkey pin into a steep falling waveform and stabilize the input voltage within eight cycles (1 s when f(x in ) = 8 mhz) from the moment the input voltage reaches v il or lower. the actual threshold voltage fo r the adkey pin is between v ih and v il . to prevent unnecessary adkey operation due to noise or other factors, set the adkey pin voltage to v ih (0.9 v cc ) or more while the input is waited. 6. register operation during a/d conversion the a/d conversion operation is not guaranteed if the following are preformed: ? the cpu mode register is operated during a/d conversion operation ? the ad control register is operated during a/d conversion operation ? the stp or wit instructi on is executed during a/d conversion operation 7. a/d converter power source pin connect to the a/d converter power source pin to av ss or v ss whether the a/d conversion function is used or not. if the av ss pin is left open, the mcu may operate incorrectly because the pin will be affect ed by noise or other factors.
rev.3.02 apr 10, 2008 page 126 of 131 rej03b0177-0302 38d2 group notes on lcd drive control circuit 1. setting data to lcd display ram to write data to the lcd display ram when the lcd enable bit is set to ?1? and while lcd is turned on, set fixed data. rewriting with temporary data may cause lcd to flicker. the following shows a processing exam ple to write data to the lcd display ram while lcd is turned on. fig. 104 processing example when writing data to lcd display ram while lcd turned on (1) ccorrect processing lcd on lcd on or off *content at address 0040 16 : ?ff 16 ? off on set lcd display ram data lram0 (address 0040 16 ) ?ff 16 ? lcd on or off? set lcd display ram data lram0 (address 0040 16 ) ?00 16 ? ? set fixed data to lcd display ram (2) incorrect processing lcd on lcd on or off *content at address 0040 16 : ?ff 16 ? off on set lcd display ram data lram0 (address 0040 16 ) ?ff 16 ? lcd on or off? set lcd display ram data lram0 (address 0040 16 ) ?00 16 ? ? set off data to lcd display ram lcd off ? set fixed data to lcd display ram
rev.3.02 apr 10, 2008 page 127 of 131 rej03b0177-0302 38d2 group 2. executing stp instruction execution of the stp instruction sets the lcd enable bit (bit 3 of the lcd mode register) and bits 0 to 5 and bit 7 of the lcd power control register to ?0? and the lcd panel turns off. to make the lcd panel turn on after returning from the stop mode, set these bits to ?1?. 3. v l3 pin to use the lcd drive control circuit while v l3 is set to the voltage equal to v cc , apply the v cc voltage to the v l3 pin and write ?1? to the v l3 connection bit of lcd power control register (address 0038 16 )). 4. lcd drive power supply power supply capacitor may be in sufficient with the division resistance for lcd power supply, and the characteristic of the lcd panel. in this case, there is the method of connecting the bypass capacitor about 0.1 ? 0.33 f to v l1 ? v l3 pins. the example of a strengthening measure of the lcd drive power supply is shown below. fig. 105 strengthening measure example of lcd drive power supply notes on rom correction function 1. returning to main program to return to the main program from the correction program, use the jmp instruction (3-byte instruction). 2. using rom correction function if the rom correction function is used, be sure to enable the rom correction enable bit afte r setting the rom correction register. 3. address do not set addresses other th an the rom area in the rom correction address regi sters. also, do not se t the same address in the rom correction address 1 register and the rom correction address 2 register. 4. rom correction process include the rom correction proc ess in the program beforehand. 5. using no rom correction function if the rom correction function is not used, the rom correction vector can be used as normal ram/rom. when using as normal ram/rom, be sure to set bits 1 and 0 of the rom correction enable register to ?0? (disabled). notes on clock generating circuit 1. oscillation circuit constants the oscillation circui t constants vary depending on the resonator. use values recommended by th e oscillator manufacturer. a feed-back resistor is implemented between the x in and x out pins (an external feed-back resi stor may be required depending on conditions). as no feed-back re sistor is implemented between x cin and x cout , add a feedback resistor of about 10 m . 2. transition between modes when the mcu transits between on-chip oscillator mode, x in mode, or low-speed mode, both the x in and x cin oscillations must be stabilized. be especially careful when turning the power on and returning from stop mode. refer to the clock state transition diagram for a trans ition between each mode. also, set the frequency in the condition that f(x in ) 3 (x cin ). when x in mode is not used (the x in -x out oscillation or external clock input to x in is not performed), connect x in to v cc through a resistor. 3. oscillation stabilization before executing the stp instructio n, set the values * to generate the wait time required for oscillation stabilization to timer 1 latch and timer 2 latch (low-order 8 bits of timer 1 and high-order 8 bits of timer 2). *referential values (set values according to your oscillator and system) ? oscsel = ?l? in the flash memory and qzrom versions: ..................................................................... 0005 16 or more ?oscsel = ?h? in th e qzrom version: .....................................................................01ff 16 or more 4. low-speed mode, x in mode to use low-speed mode or x in mode, wait until oscillation stabilizes after enabling the x in -x out and x cin -x cout oscillation, then switch to the mode. ? connect by the shortest possible wiring. ? connect the bypass capacitor to the v l1 ? v l3 pins as short as possible. (referential value:0.1 ? 0.33 f) v l3 v l2 v l1
rev.3.02 apr 10, 2008 page 128 of 131 rej03b0177-0302 38d2 group notes on flash memory mode ? cpu rewrite mode (1) operating speed during cpu rewrite mode, set the system clock to 4.0 mhz or less using the main clock division ratio selection bits (bits 6 and 7 of address 003b 16 ). (2) prohibited instructions during cpu rewrite mode, the inst ructions which reference data in the flash memory cannot be used. (3) interrupts during cpu rewrite mode, interrupts cannot be used because they reference data in the flash memory. (4) watchdog timer if the watchdog timer has been runni ng already, the internal reset by underflow will not occur because the watchdog timer is continuously cleared during program or erase operation. (5) reset reset is always valid. if cnv ss = ?h? when a reset is released, boot mode is active. the program starts from the address stored in addresses fffc 16 and fffd 16 in boot rom area. notes on watchdog timer 1. watchdog timer underflow the watchdog timer does not ope rate in stop mode, but it continues counting duri ng the wait time to release the stop state and in wait mode. wr ite to the watchdog time r control register so that the watchdog timer will not underflow during these periods. 2. stopping on-chip oscillator oscillation when the on-chip oscillator is selected by the watchdog timer count source selection bit 2, the on-chip oscillator forcibly oscillates and it cannot be stopped. also, in this time, set the stp instruction function selection bit to ?1? at this time. select ?0? ( source) for the watchdog timer count source selection bit 2 at the system wh ich on-chip oscill ator is stopped. 3. watchdog timer control register bits 7 to 5 can be re written only once after a reset. after writing, rewriting is disabled because they are locked. these bits are set to ?0? after a reset. notes on differences between qzrom version and flash memory version the flash memory and qzrom versions differ in their manufacturing processes, built- in rom, memory size, and layout patterns. because of th ese differences, characteristic values, operation margins, noise immunity, and noise radiation and oscillation circuit constants may vary within the specified range of electrical characteristics. when switching to the qzrom version, implement system evaluations equivalent to thos e performed in the flash memory version. confirm page 11 about the differences of functions. notes on power source voltage when the power supply voltage value of the mcu is less than the value indicated in the reco mmended operating conditions, the mcu may not operate normally an d perform unstable operation. in a system where the power source voltage drops slowly when the power source voltage drops or the power is turned off, reset the mcu when the power source voltage is less than the recommended operating conditions , and design the system so that this unstable operation does not cause errors to it. notes on handling power source pins before using the mcu, connect a capacitor suitable for high frequencies as a bypass capacito r between the following: the power source pin (v cc pin) and the gnd pin (v ss pin) the power source pin (v cc pin) and the analog power source input pin (av ss pin). as a bypass capacitor, a ceramic capacitor of 0.01 f to 0.1 f is recommended. also, use the shortest possible wiring to connect a bypass capacitor between the power so urce pin and the gnd pin and between the power source pin a nd the analog power source pin. notes on memory 1. ram the ram content is undefined at a re set. be sure to set the initial value before use.
rev.3.02 apr 10, 2008 page 129 of 131 rej03b0177-0302 38d2 group notes on qzrom version wiring to oscsel pin (1) oscsel = l connect the oscsel pin the s hortest possible to the gnd pattern which is supplied to the v ss pin of the microcomputer. in addition connecting an approximately 5 k resistor in series to the gnd could improve noise immunity. in this case as well as the above mention, connect the pi n the shortest possible to the gnd pattern which is supplied to the v ss pin of the microcomputer. (2) oscsel = h connect the oscsel pin the shortest possible to the v cc pattern which is supplied to the v cc pin of the microcomputer. in addition connecting an approximately 5 k resistor in series to the v cc could improve noise immunity. in this case as well as the above mention, connect the pi n the shortest possible to the v cc pattern which is supplied to the v cc pin of the microcomputer. the oscsel pin is the power source input pin for the built-in qzrom. when programming in the qzrom, the impedance of the oscsel pin is low to allow th e electric current for writing to flow into the built-in qzrom. b ecause of this, noise can enter easily. if noise enters the oscs el pin, abnormal instruction codes or data are read from the qzrom, which may cause a program runaway. fig. 106 wiring for oscsel pin overvoltage in qzrom version make sure that voltage exceeding the v cc pin voltage is not applied to other pins. in particular , ensure that the state indicated by bold lines in figure below does not occur for pin oscsel pin (v pp power source pin for qzrom) during power-on or power- off. otherwise the contents of qzrom could be rewritten. fig. 107 timing diagram (bold-lined periods are applicable) qzrom version product shipped in blank as for the product shipped in blank, renesas does not perform the writing test to user rom area after the assembly process though the qzrom writing test is performed enough before the assembly process. therefore, a writing error of approximate 0.1% may occur. moreover, please note the contac t of cables and foreign bodies on a socket, etc. because a writing environment may cause some writing errors. ordering qzrom writing 1. notes on qzrom writing orders when ordering the qzrom product shipped after writing, submit the mask file (extension: .msk) which is made by the mask file converter mm. ? be sure to set the rom option data* setup when making the mask file by using the mask file converter mm.. the rom code protect is specified acco rding to the rom option data* in the mask file which is submitted at ordering. note that the mask file which has nothing at the rom option data* or has the data other than ?00 16 ?, ?fe 16 ? and ?ff 16 ? can not be accepted. ?set ?ff 16 ? to the rom code protect address in rom data regardless of the presence or ab sence of a protect. when data other than ?ff 16 ? is set, we may ask that the rom data be submitted again. * rom option data: mask option noted in mm 2. data required for qzrom ordering the following are necessary when ordering a qzrom product shipped after writing: ? qzrom writing confirmation form* ? mark specification form* ? rom data: mask file * for the qzrom writing confirmation form and the mark specification form, refer to th e ?renesas technology corp.? homepage (http://www.ren esas.com/homepage.jsp). note that we cannot deal with special font marking (customer's trademark etc.) in qzrom microcomputer. 3. qzrom product receiving procedure when writing to qzrom is performed by user side, the receiving inspection by the fo llowing flow is necessary. oscsel v ss the shortest the shortest about 5 k termination of oscsel pin oscsel v cc the shortest the shortest about 5 k (1) oscsel = l (2) oscsel = h (1) (1) (1) (1) note 1: it shows the microcomputers pin v cc pin voltage oscsel pin voltage ?h? input oscsel pin voltage ?l? input 1.8v 1.8v (1) input voltage to other mcu pins rises before v cc pin voltage. (2) input voltage to other mcu pins falls after v cc pin voltage. note: the internal circuitry is unstable when v cc is below the minimum voltage specification of 1.8 v (shaded portion), so particular care should be exercised regarding overvoltage. (1) (2)
rev.3.02 apr 10, 2008 page 130 of 131 rej03b0177-0302 38d2 group fig. 108 qzrom receiving procedure notes on flash memory version cpu rewrite mode 1. operating speed qzrom product shipped in blank programming verify test receiving inspection of unprotected area (verify test) programming to unprotected area verify test for unprotected area shipping user qzrom product shipped after writing ?protect disabled? ?protect enabled to the protect area 1? renesas receiving inspection (blank check) programming verify test for all area shipping user renesas
rev.3.02 apr 10, 2008 page 131 of 131 rej03b0177-0302 38d2 group during cpu rewrite mode , set the system clock 4.0 mhz or less using the main clock division ratio selection bits (bits 6 and 7 of address 003b 16 ). 2. prohibited instructions the instructions which refer to the internal data of the flash memory cannot be used dur ing the cpu rewrite mode. 3. interrupts the interrupts cannot be used during the cpu rewrite mode because they refer to the internal data of the flash memory. 4. watchdog timer in case of the watchdog timer has been running already, the internal reset generated by watchdog timer underflow does not happen, because of watchdog timer is always clearing during program or erase operation. 5. reset reset is always vali d. in case of cnv ss = ?h? when reset is released, boot mode is active. so the program starts from the address contained in address fffc 16 and fffd 16 in boot rom area. cnv ss pin the cnv ss pin determines the flash memory mode. connect the cnv ss pin the shortest possible to the gnd pattern which is supplied to the v ss pin of the microcomputer. in addition connecting an approximately 5 k . resistor in series to the gnd could improve noise immunity. in this case as well as the above mention, connect the pi n the shortest possible to the gnd pattern which is supplied to the v ss pin of the microcomputer. note. when the boot mode or the stan dard serial i/o mode is used, a switch of the inpu t level to the cnv ss pin is required. fig. 109 wiring for cnv ss pin the shortest cnv ss v ss approx. 5k the shortest (1) (1) note 1: it shows the microcomputers pin.
(1/4) revision history 38d2 group datasheet rev. date description page summary 1.00 jan. 23, 2006 ? first edition issued 2.00 mar. 24, 2006 1 features : description of reset circuit eliminated and power source voltage revised. 3 performance overview: oscillation frequency and power source voltage revised. 4 functional block diagram : description of reset circuit eliminated. 7 fig. 4 and table 3 38d29gc, 38d29g8 added. 12 fig. 9 memory map diagram revised. 15 table 7 non-port function of port p5 4 ? p5 7 revised. related sfrs of port p4 0 and p4 1 revised. 18 fig. 15 (18) port p6 1 revised. 26 fig. 22 timer 12 mode register revised. 29 notes on timer x: (1), (2) revised. 32 ? real time port control revised. 36 fig. 32 uart control register revised. 38 fig. 34 note 1 revised. 42 fig. 38 note 2 revised. 48 fig. 46 memory map revised. 49 note 1 revised. 50 clock output function revised. 51 reset circuit revised. 53 (1)stop mode: description revised. 54 fig. 58 source added. 55 fig. 60 state transitions of system clock: note 3 revised. 56 address of oscillation ouput control register revised. 60 fig. 64 connection of x in and x out revised. 65-75 electrical characteristics added. 2.01 nov. 15, 2006 1 descriotion revised power dissipation described. 3 main clock / sub-clock generating circuits: built-in feed back resistor built-in power dissipation described. 5av ss : gnd input pin analog power source input pin 12 rom and rom code protect address : description revised. fig. 9 is revised. 15 table 7 : as for ckout, non-port function and related sfrs are added. 19 termination of unused pins : as for i/o ports, description added. v l3 : terminations 1 and 2 revised. 25 timer 1, timer 2 : description revised. 28 timer x : description revised. 29 fig. 24 : txcon1 bit 5 = 1 txcon1 bit 5 = 0 31 timer y : description revised. fig. 26 : note added. 37 fig. 33 : note and source added. revision history
(2/4) revision history 38d2 group datasheet 2.01 nov. 15, 2006 42 lcd power circuit ? description added ? fig. 38 : note 3 eliminated ? fig. 39 : bit name described 48 fig. 46 : reserved rom area address revised. rom correction function : description added. 49 fig. 48 : on-chip oscillator on-chip oscillator/4 note added. fig. 49 : on-chip oscillator on-chip oscillator/4 source/1024 count sorce/1024 source/4 count sorce/4 53 (5) low-speed mode : description added 54 fig. 58 : note added and circuit expression is revised. 56 fig. 61 : circuit expression is revised. 57 table 12: as for v ref and av ss , function revised. 59 to 62 fig. 63 to fig. 66 added and revised. 71 table 17 i ih and i il : oscsel added. 75 table 23: note revised. 3.01 sep.18, 2007 ? flash memory version function: added 1 description: flash memory version contents added features: flash memory version contents added power source voltages: flash memory version contents added power dissipation: flash memory version contents added flash memory mode: added 2 fig. 1: note is added 3 table 1: power source voltage: revised and flash memory version contents added power dissipation: flash memory version contents added 5 table 2: led 0 to 7 and kw 0 to 3 are added to pin name 6 pin discription table is divided (to table 2 and table 3) table 3: cnv ss pin is added 7 fig. 3: f (flash memory) is added to memory type 8 flash memory size is added fig. 4: some ?under developing? are erased 9 table 3: flash memory version products are added 10 table 5 ?differences between qzrom and flash memory versions? and ?notes on differences between qzrom and flash memory versions? are added 12 fig. 6: ?push contents of processor status register on stack? position is moved 14 cpu mode register explanation is revised fig. 7: some notes are added 15 fig. 8: flash memory version flow is added 16 fig. 9: flash memory version srf is added 17 fig. 10: flash memory version srf and notes are added 19 table 2: led 0 to 7 and kw 0 to 3 are added to pin name 24-28 ?interrupt? is wholly revised 32 ?frequency divider for timer? is revised 35 ?frequency divider for timer? is revised rev. date description page summary
(3/4) revision history 38d2 group datasheet 3.01 sep.18, 2007 35 ?(6) pulse width measurement mode? is revised 36 ?(3) write to timer x? is revised 37 ?(7) when timer x pulse width measurement mode used? 38 ?(5) real time port control? is added 39 ?notes on timer y? is revised 44 ?conparator and control circuit? is revised 45 fig. 37: revised ?adkey control circuit? is revised 56 ?initial value of watchdog timer? is revised ?bit 6 of watchdog timer control register? and ?? are revised fig. 51: revised fig. 52: revised 57 fig. 54: revised ?[rrf register (rrfr)]? is added 58 explaination is revised fig. 56: revised fig. 57: notes are added 59 fig. 58: revised 60 explanation is revised 62 fig. 61: revised 63 fig. 62: revised 65 table 14: revised 71-88 ?flash memory mode? is added 89 revised to ?notes on use? from ?notes on programming? contents 90 added ?notes on qzrom version? 91 added ?notes on flash memory version? and ?notes on differences between qzrom version an d flash memory version? 94 table 21: revised 95-101 table 22 to 29: ?v ss =0v? are added to condition 95 table 22: v il of x cin is deleted 98 table 25: ?v cc = 4.0 t o 5.0 v? ?v cc = 1.8 to 5.5 v? 100 table 28: ? abs of 10bitad mode ?2.2v < v cc 4.0v? ?2.2v v cc 4.0v? ?1.8v v cc 5.5v? ?2.0v v cc 5.5v ? ? abs of 8bitad mode ?2.2v < v cc 4.0v? ?2.2v v cc 4.0v? ?1.8v v cc 5.5v? ?2.0v v cc 5.5v? ?t conv is separated to 10bitad mode and 8bitadmode, and note is added 102 table 30: t c , t wh , and t wl of x in ?4.5 v to 5.5 v? ?4.5v v cc 5.5v? ?4.0 v to 5.5 v? ?4.0v v cc 5.5v? table 31: t c of x in and cntr, and t wh and t wl of x in ?2.0v < v cc 4.0v? ?2.0v v cc 4.0v? ?v cc 2.0v? ?v cc < 2.0v? 104 fig. 95: x cin timing is deleted 105-115 flash memory version electrical characteristics is added rev. date description page summary
(4/4) revision history 38d2 group datasheet 3.01 sep.18, 2007 118-131 appendix is added 3.02 apr. 09, 2008 2 fig. 1: revised 3 table 1: revised 5 table 2: revised 18 ?direction registers?: peripheral output name is added and deleted 21 fig. 14: revised 23 table 9: revised 25 ?external interrupt pin selection? is deleted 26 fig. 17:revised 29 port name is revised 34 fig. 26: revised 38 ?timer y? is revised 44 fig. 36: revised 49 fig. 41: revised 57 fig. 53 and 54 are revised 58 fig. 56: revised 63 fig. 63: revised 64 fig. 63: revised 65 table 14: revised 66 fig. 65: revised 74 fig. 73: revised 85 fig. 80: revised 86 fig. 81: revised 90 notes on rom code protect is revised 95 table 22: revised 99 table 27: revised 102 table 30: revised 109 note of table 38: revised 110 table 40: revised 129 notes on rom code protect is revised rev. date description page summary
notes: 1. this document is provided for reference purposes only so that renesas customers may select the appropriate renesas product s for their use. renesas neither makes warranties or representations with respect to the accuracy or completeness of the information contained in this document nor grants any license to any intellectual property rights or any other rights of renesas or any third party with respect to the information in this document. 2. renesas shall have no liability for damages or infringement of any intellectual property or other rights arising out of t he use of any information in this document, including, but not limited to, product data, diagrams, charts, programs, algorithms, and application circuit examples. 3. you should not use the products or the technology described in this document for the purpose of military applications such as the development of weapons of mass destruction or for the purpose of any other military use. when exporting the products or technology described herein, you should follow the applicable export control laws and regulations, and procedures required by such laws and regulations. 4. all information included in this document such as product data, diagrams, charts, programs, algorithms, and application ci rcuit examples, is current as of the date this document is issued. such information, however, is subject to change without any prior notice. before purchasing or using any renesas products listed in this document, please confirm the latest product information with a renesas sales office. also, please pay regular and careful attentio n to additional and different information to be disclosed by renesas such as that disclosed through our website. (http://www.renesas.com ) 5. renesas has used reasonable care in compiling the information included in this document, but renesas assumes no liability whatsoever for any damages incurred as a result of errors or omissions in the information included in this document. 6. when using or otherwise relying on the information in this document, you should evaluate the information in light of the t otal system before deciding about the applicability of such information to the intended application. renesas makes no representations, warranties or guaranties regarding th e suitability of its products for any particular application and specifically disclaims any liability arising out of the application and use of the information in this do cument or renesas products. 7. with the exception of products specified by renesas as suitable for automobile applications, renesas products are not desi gned, manufactured or tested for applications or otherwise in systems the failure or malfunction of which may cause a direct threat to human life or create a risk of h uman injury or which require especially high quality and reliability such as safety systems, or equipment or systems for transportation and traffic, healthcare, combustion co ntrol, aerospace and aeronautics, nuclear power, or undersea communication transmission. if you are considering the use of our products for such purposes, please contact a r enesas sales office beforehand. renesas shall have no liability for damages arising out of the uses set forth above. 8. notwithstanding the preceding paragraph, you should not use renesas products for the purposes listed below: (1) artificial life support devices or systems (2) surgical implantations (3) healthcare intervention (e.g., excision, administration of medication, etc.) (4) any other purposes that pose a direct threat to human life renesas shall have no liability for damages arising out of the uses set forth in the above and purchasers who elect to us e renesas products in any of the foregoing applications shall indemnify and hold harmless renesas technology corp., its affiliated companies and their officers, dir ectors, and employees against any and all damages arising out of such applications. 9. you should use the products described herein within the range specified by renesas, especially with respect to the maximum rating, operating supply voltage range, movement power voltage range, heat radiation characteristics, installation and other product characteristics. renesas sha ll have no liability for malfunctions or damages arising out of the use of renesas products beyond such specified ranges. 10. although renesas endeavors to improve the quality and reliability of its products, ic products have specific characteristic s such as the occurrence of failure at a certain rate and malfunctions under certain use conditions. please be sure to implement safety measures to guard against the poss ibility of physical injury, and injury or damage caused by fire in the event of the failure of a renesas product, such as safety design for hardware and software includin g but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other applicable measures. among others, sinc e the evaluation of microcomputer software alone is very difficult, please evaluate the safety of the final products or system manufactured by you. 11. in case renesas products listed in this document are detached from the products to which the renesas products are attached or affixed, the risk of accident such as swallowing by infants and small children is very high. you should implement safety measures so that renesas products may not be easily detached from your products. renesas shall have no liability for damages arising out of such detachment. 12. this document may not be reproduced or duplicated, in any form, in whole or in part, without prior written approval from r enesas. 13. please contact a renesas sales office if you have any questions regarding the information contained in this document, renes as semiconductor products, or if you have any other inquiries. sales strategic planning div. nippon bldg., 2-6-2, ohte-machi, chiyoda-ku, tokyo 100-0004, japan http://www.renesas.com refer to " http://www.renesas.com/en/network " for the latest and detailed information. renesas technology america, inc. 450 holger way, san jose, ca 95134-1368, u.s.a tel: <1> (408) 382-7500, fax: <1> (408) 382-7501 renesas technology europe limited dukes meadow, millboard road, bourne end, buckinghamshire, sl8 5fh, u.k. tel: <44> (1628) 585-100, fax: <44> (1628) 585-900 renesas technology (shanghai) co., ltd. unit 204, 205, aziacenter, no.1233 lujiazui ring rd, pudong district, shanghai, china 200120 tel: <86> (21) 5877-1818, fax: <86> (21) 6887-7858/7898 renesas technology hong kong ltd. 7th floor, north tower, world finance centre, harbour city, canton road, tsimshatsui, kowloon, hong kong tel: <852> 2265-6688, fax: <852> 2377-3473 renesas technology taiwan co., ltd. 10th floor, no.99, fushing north road, taipei, taiwan tel: <886> (2) 2715-2888, fax: <886> (2) 3518-3399 renesas technology singapore pte. ltd. 1 harbour front avenue, #06-10, keppel bay tower, singapore 098632 tel: <65> 6213-0200, fax: <65> 6278-8001 renesas technology korea co., ltd. kukje center bldg. 18th fl., 191, 2-ka, hangang-ro, yongsan-ku, seoul 140-702, korea tel: <82> (2) 796-3115, fax: <82> (2) 796-2145 renesas technology malaysia sdn. bhd unit 906, block b, menara amcorp, amcorp trade centre, no.18, jln persiaran barat, 46050 petaling jaya, selangor darul ehsan, m alaysia tel: <603> 7955-9390, fax: <603> 7955-9510 renesas sales offices ? 2008. renesas technology corp., all rights reserved. printed in japan. colophon .7.2


▲Up To Search▲   

 
Price & Availability of M38D2

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X